Spaces:
Running
Running
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- Dockerfile +8 -19
- README.md +13 -7
- 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 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: docker
|
| 7 |
-
|
| 8 |
-
license: mit
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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=
|
| 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
|