Spaces:
Sleeping
Sleeping
JoshuaCarrera commited on
Commit ·
f673aa2
1
Parent(s): 773fc20
Actualizar enlaces y ajustes para los .onnx
Browse files- Dockerfile +6 -5
- requirements.txt +3 -1
- src/app/app.py +6 -6
Dockerfile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
# 1. Usamos 3.11 por estabilidad absoluta con PyTorch y
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
# 2. Instalamos dependencias del sistema mínimas.
|
| 5 |
-
#
|
| 6 |
-
# Si estrictamente procesas video, deja ffmpeg. Si son solo imágenes, puedes borrar el RUN completo.
|
| 7 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 8 |
ffmpeg \
|
|
|
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
# --- CONFIGURACIÓN DE HUGGING FACE ---
|
|
@@ -13,6 +13,7 @@ RUN useradd -m -u 1000 user
|
|
| 13 |
USER user
|
| 14 |
|
| 15 |
# 3. Variables de entorno: PATH y Optimización estricta para CPU
|
|
|
|
| 16 |
ENV HOME=/home/user \
|
| 17 |
PATH=/home/user/.local/bin:$PATH \
|
| 18 |
OMP_NUM_THREADS=1 \
|
|
@@ -35,5 +36,5 @@ COPY --chown=user . .
|
|
| 35 |
|
| 36 |
EXPOSE 7860
|
| 37 |
|
| 38 |
-
# 7. Arranque
|
| 39 |
-
CMD ["uvicorn", "src.app.app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "
|
|
|
|
| 1 |
+
# 1. Usamos 3.11 por estabilidad absoluta con PyTorch, YOLO y ONNX sin compilar desde cero
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
# 2. Instalamos dependencias del sistema mínimas.
|
| 5 |
+
# libgomp1 es crucial para ONNX Runtime en imágenes slim de Debian
|
|
|
|
| 6 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 7 |
ffmpeg \
|
| 8 |
+
libgomp1 \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
# --- CONFIGURACIÓN DE HUGGING FACE ---
|
|
|
|
| 13 |
USER user
|
| 14 |
|
| 15 |
# 3. Variables de entorno: PATH y Optimización estricta para CPU
|
| 16 |
+
# ONNX Runtime respetará estas variables para no saturar los hilos
|
| 17 |
ENV HOME=/home/user \
|
| 18 |
PATH=/home/user/.local/bin:$PATH \
|
| 19 |
OMP_NUM_THREADS=1 \
|
|
|
|
| 36 |
|
| 37 |
EXPOSE 7860
|
| 38 |
|
| 39 |
+
# 7. Arranque optimizado para 16GB de RAM (4 workers)
|
| 40 |
+
CMD ["uvicorn", "src.app.app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "4"]
|
requirements.txt
CHANGED
|
@@ -23,6 +23,8 @@ matplotlib==3.10.9
|
|
| 23 |
mpmath==1.3.0
|
| 24 |
networkx==3.6.1
|
| 25 |
numpy==2.4.4
|
|
|
|
|
|
|
| 26 |
opencv-python-headless==4.13.0.92
|
| 27 |
packaging==26.2
|
| 28 |
pillow==12.2.0
|
|
@@ -36,8 +38,8 @@ PySocks==1.7.1
|
|
| 36 |
python-dateutil==2.9.0.post0
|
| 37 |
python-multipart==0.0.29
|
| 38 |
PyYAML==6.0.3
|
| 39 |
-
s3transfer==0.18.0
|
| 40 |
requests==2.34.2
|
|
|
|
| 41 |
scipy==1.17.1
|
| 42 |
setuptools==70.2.0
|
| 43 |
six==1.17.0
|
|
|
|
| 23 |
mpmath==1.3.0
|
| 24 |
networkx==3.6.1
|
| 25 |
numpy==2.4.4
|
| 26 |
+
onnx==1.17.0
|
| 27 |
+
onnxruntime==1.20.0
|
| 28 |
opencv-python-headless==4.13.0.92
|
| 29 |
packaging==26.2
|
| 30 |
pillow==12.2.0
|
|
|
|
| 38 |
python-dateutil==2.9.0.post0
|
| 39 |
python-multipart==0.0.29
|
| 40 |
PyYAML==6.0.3
|
|
|
|
| 41 |
requests==2.34.2
|
| 42 |
+
s3transfer==0.18.0
|
| 43 |
scipy==1.17.1
|
| 44 |
setuptools==70.2.0
|
| 45 |
six==1.17.0
|
src/app/app.py
CHANGED
|
@@ -22,15 +22,15 @@ R2_SECRET_KEY = os.getenv("R2_SECRET_KEY")
|
|
| 22 |
model_configs = {
|
| 23 |
"VEF": {
|
| 24 |
"r2_key": "files/md5/47/4668895cd0778ae1381ce2e3fdfd46",
|
| 25 |
-
"path": "models/train/VEF_model_13f/weights/best.
|
| 26 |
},
|
| 27 |
"USD": {
|
| 28 |
"r2_key": "files/md5/54/f34a7d848129a2cfbc9f9250b3e9ef",
|
| 29 |
-
"path": "models/train/USD_model_plus_01/weights/best.
|
| 30 |
},
|
| 31 |
"INFERENCIA": {
|
| 32 |
"r2_key": "files/md5/48/4833ce8e1f80f4c07e4e087feb5823",
|
| 33 |
-
"path": "models/train/USD_VEF_Model_01j/weights/best.
|
| 34 |
}
|
| 35 |
}
|
| 36 |
|
|
@@ -80,9 +80,9 @@ download_models_from_r2()
|
|
| 80 |
# 4. CARGA DE MODELOS
|
| 81 |
# ==========================================
|
| 82 |
models = {
|
| 83 |
-
"USD": YOLO(model_configs["USD"]["path"]),
|
| 84 |
-
"VEF": YOLO(model_configs["VEF"]["path"]),
|
| 85 |
-
"INFERENCIA": YOLO(model_configs["INFERENCIA"]["path"]),
|
| 86 |
}
|
| 87 |
|
| 88 |
classes = {
|
|
|
|
| 22 |
model_configs = {
|
| 23 |
"VEF": {
|
| 24 |
"r2_key": "files/md5/47/4668895cd0778ae1381ce2e3fdfd46",
|
| 25 |
+
"path": "models/train/VEF_model_13f/weights/best.onnx"
|
| 26 |
},
|
| 27 |
"USD": {
|
| 28 |
"r2_key": "files/md5/54/f34a7d848129a2cfbc9f9250b3e9ef",
|
| 29 |
+
"path": "models/train/USD_model_plus_01/weights/best.onnx"
|
| 30 |
},
|
| 31 |
"INFERENCIA": {
|
| 32 |
"r2_key": "files/md5/48/4833ce8e1f80f4c07e4e087feb5823",
|
| 33 |
+
"path": "models/train/USD_VEF_Model_01j/weights/best.onnx"
|
| 34 |
}
|
| 35 |
}
|
| 36 |
|
|
|
|
| 80 |
# 4. CARGA DE MODELOS
|
| 81 |
# ==========================================
|
| 82 |
models = {
|
| 83 |
+
"USD": YOLO(model_configs["USD"]["path"], task="detect"),
|
| 84 |
+
"VEF": YOLO(model_configs["VEF"]["path"], task="detect"),
|
| 85 |
+
"INFERENCIA": YOLO(model_configs["INFERENCIA"]["path"], task="detect"),
|
| 86 |
}
|
| 87 |
|
| 88 |
classes = {
|