Skip to content

Commit 6f949de

Browse files
committed
Fix: Docker auto --no-wandb, include models/ for API
1 parent 09294e5 commit 6f949de

3 files changed

Lines changed: 24 additions & 15 deletions

File tree

.dockerignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ __pycache__/
66
*.pyc
77
*.pyo
88
.pytest_cache/
9-
models/
10-
logs/
9+
# models/ y logs/ se incluyen para que la API tenga el modelo entrenado
1110
data/
1211
notebook/
1312
wandb/

README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ pytest tests/ -v
6666
```bash
6767
docker build -t pistachio-mlops .
6868

69-
# Entrenamiento (por defecto)
69+
# Entrenamiento (por defecto, usa --no-wandb si no hay WANDB_API_KEY)
7070
docker run --gpus all pistachio-mlops
7171

7272
# Entrenamiento sin GPU
7373
docker run pistachio-mlops
7474

75-
# API de inferencia
75+
# Entrenamiento con W&B
76+
docker run -e WANDB_API_KEY=tu_key pistachio-mlops
77+
78+
# API de inferencia (el modelo debe estar en models/ al hacer build)
7679
docker run -p 8000:8000 -e MODE=api pistachio-mlops
7780
```
7881

@@ -82,6 +85,7 @@ docker run -p 8000:8000 -e MODE=api pistachio-mlops
8285
- `POST /predict` - Clasifica una imagen de pistacho (multipart/form-data, campo `file`)
8386

8487
Ejemplo:
88+
8589
```bash
8690
curl -X POST http://localhost:8000/predict -F "file=@pistacho.jpg"
8791
```
@@ -92,22 +96,23 @@ Sweep: https://wandb.ai/14farresa-/pistachio-mlops/sweeps/2147j105
9296
Proyecto: https://wandb.ai/14farresa-/pistachio-mlops
9397

9498
El proyecto incluye un W&B Report con:
99+
95100
- Resultados del sweep (learning rate, batch size, modelo)
96101
- Comparacion de arquitecturas (BatchNorm vs Dropout)
97102
- Metricas finales (accuracy, F1, matriz de confusion)
98103

99104
### Resultados del sweep
100105

101-
| LR | Batch | Modelo | Test Acc | Test F1 |
102-
|----|-------|--------|----------|---------|
103-
| 0.001 | 32 | cnn_batchnorm | 0.931 | 0.929 |
104-
| 0.001 | 32 | cnn_dropout | 0.891 | 0.888 |
105-
| 0.01 | 32 | cnn_batchnorm | **0.929** | **0.926** |
106-
| 0.01 | 32 | cnn_dropout | 0.599 | 0.375 |
107-
| 0.001 | 64 | cnn_batchnorm | 0.922 | 0.920 |
108-
| 0.001 | 64 | cnn_dropout | 0.916 | 0.914 |
109-
| 0.01 | 64 | cnn_batchnorm | 0.925 | 0.923 |
110-
| 0.01 | 64 | cnn_dropout | 0.599 | 0.375 |
106+
| LR | Batch | Modelo | Test Acc | Test F1 |
107+
| ----- | ----- | ------------- | --------- | --------- |
108+
| 0.001 | 32 | cnn_batchnorm | 0.931 | 0.929 |
109+
| 0.001 | 32 | cnn_dropout | 0.891 | 0.888 |
110+
| 0.01 | 32 | cnn_batchnorm | **0.929** | **0.926** |
111+
| 0.01 | 32 | cnn_dropout | 0.599 | 0.375 |
112+
| 0.001 | 64 | cnn_batchnorm | 0.922 | 0.920 |
113+
| 0.001 | 64 | cnn_dropout | 0.916 | 0.914 |
114+
| 0.01 | 64 | cnn_batchnorm | 0.925 | 0.923 |
115+
| 0.01 | 64 | cnn_dropout | 0.599 | 0.375 |
111116

112117
**Conclusion:** BatchNorm supera significativamente a Dropout. LR=0.01 con Dropout colapsa (predice solo una clase).
113118

entrypoint.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ if [ "$MODE" = "api" ]; then
77
echo "Arrancando API de inferencia..."
88
exec uvicorn src.api_inferencia:app --host 0.0.0.0 --port ${PORT:-8000}
99
elif [ "$MODE" = "train" ]; then
10+
WANDB_ARGS=""
11+
if [ -z "$WANDB_API_KEY" ]; then
12+
echo "WANDB_API_KEY no definida, ejecutando sin W&B."
13+
WANDB_ARGS="--no-wandb"
14+
fi
1015
echo "Arrancando entrenamiento..."
11-
exec python src/main.py configuracion.yaml
16+
exec python src/main.py configuracion.yaml $WANDB_ARGS
1217
else
1318
echo "MODE desconocido: $MODE. Usa 'train' o 'api'."
1419
exit 1

0 commit comments

Comments
 (0)