Spaces:
Sleeping
Sleeping
sam0ed commited on
Commit ·
7a4f715
1
Parent(s): a655d34
Convert to Docker Space setup
Browse files- .dockerignore +36 -0
- Dockerfile +67 -0
- README.md +2 -4
- docker-compose.yml +15 -0
- requirements.txt +4 -4
.dockerignore
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Git
|
| 2 |
+
.git
|
| 3 |
+
.gitignore
|
| 4 |
+
.gitattributes
|
| 5 |
+
|
| 6 |
+
# Python
|
| 7 |
+
__pycache__/
|
| 8 |
+
*.py[cod]
|
| 9 |
+
*$py.class
|
| 10 |
+
*.so
|
| 11 |
+
.Python
|
| 12 |
+
env/
|
| 13 |
+
venv/
|
| 14 |
+
.env
|
| 15 |
+
.venv/
|
| 16 |
+
|
| 17 |
+
# IDE
|
| 18 |
+
.vscode/
|
| 19 |
+
.cursor/
|
| 20 |
+
*.swp
|
| 21 |
+
*.swo
|
| 22 |
+
*~
|
| 23 |
+
|
| 24 |
+
# OS
|
| 25 |
+
.DS_Store
|
| 26 |
+
Thumbs.db
|
| 27 |
+
|
| 28 |
+
# Documentation
|
| 29 |
+
README.md
|
| 30 |
+
|
| 31 |
+
# Working directories (will be created by the app)
|
| 32 |
+
data/working/*
|
| 33 |
+
data/output/*
|
| 34 |
+
|
| 35 |
+
# Environment files (should be passed as build args or runtime env vars)
|
| 36 |
+
.env
|
Dockerfile
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use Python 3.11 slim image as base
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
+
|
| 4 |
+
# Set up a new user named "user" with user ID 1000 (HF requirement)
|
| 5 |
+
RUN useradd -m -u 1000 user
|
| 6 |
+
|
| 7 |
+
# Switch to the "user" user
|
| 8 |
+
USER user
|
| 9 |
+
|
| 10 |
+
# Set home to the user's home directory
|
| 11 |
+
ENV HOME=/home/user \
|
| 12 |
+
PATH=/home/user/.local/bin:$PATH
|
| 13 |
+
|
| 14 |
+
# Set the working directory to the user's home directory
|
| 15 |
+
WORKDIR $HOME/app
|
| 16 |
+
|
| 17 |
+
# Install system dependencies for OpenCV, Graphviz, and other packages
|
| 18 |
+
# Switch to root temporarily for system package installation
|
| 19 |
+
USER root
|
| 20 |
+
RUN apt-get update && apt-get install -y \
|
| 21 |
+
graphviz \
|
| 22 |
+
libgraphviz-dev \
|
| 23 |
+
libglib2.0-0 \
|
| 24 |
+
libsm6 \
|
| 25 |
+
libxext6 \
|
| 26 |
+
libxrender-dev \
|
| 27 |
+
libgomp1 \
|
| 28 |
+
libgl1-mesa-glx \
|
| 29 |
+
libgtk-3-0 \
|
| 30 |
+
libavcodec-dev \
|
| 31 |
+
libavformat-dev \
|
| 32 |
+
libswscale-dev \
|
| 33 |
+
libv4l-dev \
|
| 34 |
+
libxvidcore-dev \
|
| 35 |
+
libx264-dev \
|
| 36 |
+
libjpeg-dev \
|
| 37 |
+
libpng-dev \
|
| 38 |
+
libtiff-dev \
|
| 39 |
+
libatlas-base-dev \
|
| 40 |
+
python3-dev \
|
| 41 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 42 |
+
|
| 43 |
+
# Switch back to user
|
| 44 |
+
USER user
|
| 45 |
+
|
| 46 |
+
# Copy requirements first for better caching (with proper ownership)
|
| 47 |
+
COPY --chown=user requirements.txt .
|
| 48 |
+
|
| 49 |
+
# Install Python dependencies
|
| 50 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 51 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 52 |
+
|
| 53 |
+
# Copy the application code (with proper ownership)
|
| 54 |
+
COPY --chown=user . $HOME/app
|
| 55 |
+
|
| 56 |
+
# Create necessary directories with proper permissions
|
| 57 |
+
RUN mkdir -p data/demos data/working data/output data/templates
|
| 58 |
+
|
| 59 |
+
# Set environment variables
|
| 60 |
+
ENV PYTHONPATH=$HOME/app
|
| 61 |
+
ENV PYTHONUNBUFFERED=1
|
| 62 |
+
|
| 63 |
+
# Expose the port that Gradio uses
|
| 64 |
+
EXPOSE 7860
|
| 65 |
+
|
| 66 |
+
# Run the application
|
| 67 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
|
@@ -3,12 +3,10 @@ title: Petri Net Converter Suite
|
|
| 3 |
emoji: 🔄
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
-
sdk:
|
| 7 |
-
|
| 8 |
-
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
-
short_description: ' Petri net image recognition project(OGR)'
|
| 12 |
---
|
| 13 |
|
| 14 |
# Petri Net Converter Suite
|
|
|
|
| 3 |
emoji: 🔄
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
|
|
|
| 8 |
pinned: false
|
| 9 |
license: mit
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
# Petri Net Converter Suite
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
petri-net-converter:
|
| 5 |
+
build: .
|
| 6 |
+
ports:
|
| 7 |
+
- "7860:7860"
|
| 8 |
+
environment:
|
| 9 |
+
- GROQ_API_KEY=${GROQ_API_KEY}
|
| 10 |
+
- ROBOFLOW_API_KEY=${ROBOFLOW_API_KEY}
|
| 11 |
+
volumes:
|
| 12 |
+
# Optional: Mount data directory to persist outputs
|
| 13 |
+
- ./data/output:/app/data/output
|
| 14 |
+
- ./data/demos:/app/data/demos
|
| 15 |
+
restart: unless-stopped
|
requirements.txt
CHANGED
|
@@ -3,8 +3,8 @@ gradio>=5.0.0
|
|
| 3 |
python-dotenv>=1.0.0
|
| 4 |
|
| 5 |
# Machine Learning Framework (required by python-doctr)
|
| 6 |
-
torch>=2.
|
| 7 |
-
torchvision>=0.
|
| 8 |
|
| 9 |
# Computer Vision and Image Processing
|
| 10 |
opencv-python>=4.8.0
|
|
@@ -25,7 +25,7 @@ supervision>=0.20.0
|
|
| 25 |
requests>=2.31.0
|
| 26 |
|
| 27 |
# Petri Net Processing
|
| 28 |
-
pm4py==2.
|
| 29 |
|
| 30 |
# Template Engine
|
| 31 |
Jinja2>=3.1.0
|
|
@@ -36,4 +36,4 @@ groq>=0.4.0
|
|
| 36 |
# Utility Libraries (likely used by dependencies above)
|
| 37 |
# These may be automatically installed but listing for clarity
|
| 38 |
matplotlib>=3.7.0 # Used by various CV libraries
|
| 39 |
-
scipy>=1.11.0 # Used by scikit-image and other scientific packages
|
|
|
|
| 3 |
python-dotenv>=1.0.0
|
| 4 |
|
| 5 |
# Machine Learning Framework (required by python-doctr)
|
| 6 |
+
torch>=2.5.0
|
| 7 |
+
torchvision>=0.20.0
|
| 8 |
|
| 9 |
# Computer Vision and Image Processing
|
| 10 |
opencv-python>=4.8.0
|
|
|
|
| 25 |
requests>=2.31.0
|
| 26 |
|
| 27 |
# Petri Net Processing
|
| 28 |
+
pm4py==2.7.15.1
|
| 29 |
|
| 30 |
# Template Engine
|
| 31 |
Jinja2>=3.1.0
|
|
|
|
| 36 |
# Utility Libraries (likely used by dependencies above)
|
| 37 |
# These may be automatically installed but listing for clarity
|
| 38 |
matplotlib>=3.7.0 # Used by various CV libraries
|
| 39 |
+
scipy>=1.11.0 # Used by scikit-image and other scientific packages
|