AsamiYukiko commited on
Commit
f69f2cb
·
1 Parent(s): 7fcff4a

Fix: HF Spaces Dockerfile (UID 1000, port 7860, single worker), update onnxruntime>=1.18.1

Browse files
Files changed (3) hide show
  1. Dockerfile +8 -19
  2. README.md +13 -7
  3. requirements.txt +1 -1
Dockerfile CHANGED
@@ -1,24 +1,13 @@
1
- # ── PV Defect Classifier — Docker Image ──
2
- # Lightweight Python image, ~350MB final size
3
  FROM python:3.11-slim
4
-
5
  WORKDIR /app
6
-
7
- # Install dependencies first (cache layer)
8
  COPY requirements.txt .
9
  RUN pip install --no-cache-dir -r requirements.txt
10
-
11
- # Copy app code
12
- COPY app.py .
13
- COPY templates/ templates/
14
- COPY static/ static/
15
- COPY models/ models/
16
-
17
- # Expose port (HF Spaces requires 7860)
18
- EXPOSE 7860
19
-
20
- # Production server (gunicorn instead of Flask dev server)
21
  RUN pip install --no-cache-dir gunicorn
22
-
23
- # Run with gunicorn: 2 workers, bind to all interfaces
24
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "30", "app:app"]
 
 
 
 
 
 
 
1
  FROM python:3.11-slim
2
+ RUN useradd -m -u 1000 user
3
  WORKDIR /app
 
 
4
  COPY requirements.txt .
5
  RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
6
  RUN pip install --no-cache-dir gunicorn
7
+ COPY --chown=user app.py .
8
+ COPY --chown=user templates/ templates/
9
+ COPY --chown=user models/ models/
10
+ USER user
11
+ ENV HOME=/home/user \
12
+ PATH=/home/user/.local/bin:$PATH
13
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]
README.md CHANGED
@@ -1,11 +1,17 @@
1
  ---
2
- title: Pv Classifier
3
- emoji: 📊
4
- colorFrom: indigo
5
- colorTo: red
6
  sdk: docker
7
- pinned: false
8
- license: mit
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
1
  ---
2
+ title: PV Defect Classifier
3
+ emoji: ☀️
4
+ colorFrom: blue
5
+ colorTo: green
6
  sdk: docker
7
+ app_port: 7860
 
8
  ---
9
 
10
+ # PV Defect Classification System
11
+
12
+ A lightweight cloud-edge defect detection system for photovoltaic cells.
13
+ Powered by EfficientNet-B0 (ONNX Runtime).
14
+
15
+ - Upload a PV cell image to classify it as DEFECTIVE or NORMAL
16
+ - REST API available at /predict
17
+ - Health check at /health
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
  flask==3.0.0
2
- onnxruntime==1.17.0
3
  Pillow==10.2.0
4
  numpy==1.26.3
 
1
  flask==3.0.0
2
+ onnxruntime>=1.18.1
3
  Pillow==10.2.0
4
  numpy==1.26.3