Zunayedthebot commited on
Commit
42a1174
·
verified ·
1 Parent(s): 9721669

Upload 5 files

Browse files
Files changed (5) hide show
  1. Dockerfile +28 -0
  2. README.md +15 -6
  3. app.py +35 -0
  4. app_hf.py +9 -0
  5. requirements_hf.txt +11 -0
Dockerfile ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ libgl1-mesa-glx \
8
+ libglib2.0-0 \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # Copy requirements and install Python packages
12
+ COPY requirements_hf.txt requirements.txt
13
+ RUN pip install --no-cache-dir -r requirements.txt
14
+
15
+ # Copy application files
16
+ COPY . .
17
+
18
+ # Create necessary directories
19
+ RUN mkdir -p static/uploads static/processed data
20
+
21
+ # Expose port
22
+ EXPOSE 7860
23
+
24
+ # Set environment variables
25
+ ENV PYTHONUNBUFFERED=1
26
+
27
+ # Run the application
28
+ CMD ["python", "app_hf.py"]
README.md CHANGED
@@ -1,12 +1,21 @@
1
  ---
2
- title: Tex2lab
3
- emoji: 📚
4
- colorFrom: yellow
5
  colorTo: green
6
  sdk: docker
 
7
  pinned: false
8
- license: mit
9
- short_description: Scribble
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Tex2Lab
3
+ emoji: 📐
4
+ colorFrom: blue
5
  colorTo: green
6
  sdk: docker
7
+ app_port: 7860
8
  pinned: false
 
 
9
  ---
10
 
11
+ # Tex2Lab
12
+
13
+ Math to LaTeX conversion tool with AI-powered recognition.
14
+
15
+ Features:
16
+ - Math image to LaTeX
17
+ - Camera to LaTeX
18
+ - Table detection
19
+ - PDF processing
20
+ - Scribble to LaTeX
21
+ - Graph generation
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ from flask import Flask, render_template
3
+ from flask_login import login_required
4
+ from controller.pix2text_controller import pix2text_bp
5
+ from controller.table_controller import table_bp
6
+ from controller.scribble_controller import scribble_bp
7
+ from controller.pdf_controller import pdf_bp
8
+ from controller.graph_controller import graph_bp
9
+ from controller.auth_controller import auth_bp, init_app
10
+ from controller.pdffly_controller import pdffly_bp
11
+
12
+ app = Flask(__name__)
13
+ app.secret_key = 'your-secret-key-here' # In production, use a secure secret key
14
+
15
+ # Initialize login manager
16
+ init_app(app)
17
+
18
+ # Register blueprints
19
+ app.register_blueprint(pix2text_bp)
20
+ app.register_blueprint(table_bp)
21
+ app.register_blueprint(scribble_bp)
22
+ app.register_blueprint(pdf_bp)
23
+ app.register_blueprint(pdffly_bp, url_prefix='/pdffly')
24
+ app.register_blueprint(graph_bp)
25
+ app.register_blueprint(auth_bp, url_prefix='/auth')
26
+
27
+ @app.route('/')
28
+ @login_required
29
+ def index():
30
+ return render_template('index.html')
31
+
32
+ if __name__ == '__main__':
33
+ import os
34
+ port = int(os.environ.get('PORT', 5000))
35
+ app.run(debug=False, host='0.0.0.0', port=port)
app_hf.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Hugging Face Spaces entry point
3
+ """
4
+ import os
5
+ from app import app
6
+
7
+ if __name__ == "__main__":
8
+ # Hugging Face Spaces uses port 7860
9
+ app.run(host="0.0.0.0", port=7860, debug=False)
requirements_hf.txt ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ flask
2
+ flask-login
3
+ transformers>=4.37.0
4
+ pillow
5
+ torch
6
+ PyPDF2
7
+ PyMuPDF
8
+ pix2text
9
+ werkzeug
10
+ opencv-python-headless
11
+ numpy