This repository contains the full dataset-to-model workflow for YOLO training in the Smart Sorter context. It covers:
- MinIO sync (download/upload)
- Dataset curation and split generation
- Training and validation workflows
- PT to TensorRT engine export
- Result organization and traceability
The project is structured for reproducible experiments, with explicit split versions and class-specific outputs (Caja, Vetas, mixed).
+--------------------------------------+
| MinIO Bucket |
| smartsorter-v2/{cajas,vetas,BG} |
+------------------+-------------------+
|
v
+---------------+----------------+
| scripts/minio/download_* |
| -> data/raw/minio_full/ |
+---------------+----------------+
|
v
+---------------+----------------+
| data/curated/{limpieza_*}/ |
| Manual curation and cleanup |
+---------------+----------------+
|
v
+---------------+----------------+
| scripts/data/split_dataset.py |
| -> data/splits/<version>/ |
| -> updates configs/*.yaml |
+---------------+----------------+
|
v
+-----------------+------------------+
| notebooks/training.ipynb |
| train / val / predict / gpu clean |
+-----------------+------------------+
|
v
+-----------------+------------------+
| result/{Caja|Vetas|mixed}/... |
| versioned runs and metrics |
+-----------------+------------------+
|
v
+-----------------+------------------+
| notebooks/export_pt_to_engine.ipynb|
| .pt -> TensorRT .engine |
+------------------------------------+
Training/
├── configs/
│ ├── caja.yaml
│ ├── vetas.yaml
│ └── mixto.yaml
│
├── data/
│ ├── raw/minio_full/ # Full historical sync from MinIO
│ ├── curated/
│ │ ├── limpieza_caja/ # Curated unsplit source for Caja workflows
│ │ └── limpieza_veta/ # Curated unsplit source for Vetas workflows
│ └── splits/ # Versioned split outputs (train/val/test)
│
├── model/
│ ├── yolo26n.pt # Base training model
│ └── one_class.engine # TensorRT artifact (if generated)
│
├── notebooks/
│ ├── training.ipynb # Training/validation/predict workflow
│ ├── export_pt_to_engine.ipynb # PT -> TensorRT export workflow
│ └── tuning/ray_tune.ipynb # Hyperparameter tuning
│
├── result/
│ ├── Caja/
│ └── Vetas/
│
├── scripts/
│ ├── data/
│ │ ├── split_dataset.py
│ │ ├── remap_labels_to_class0.py
│ │ └── validate_labels_images.py
│ ├── minio/
│ │ ├── download_from_minio.py
│ │ └── upload_to_minio.py
│ └── results/
│ ├── organize_results.py
│ └── README.txt
│
├── pyproject.toml
├── uv.lock
└── README.md
uv syncsource .venv/bin/activatepython3 --version
yolo --helpThe training configs are centralized in:
configs/caja.yamlconfigs/vetas.yamlconfigs/mixto.yaml
These YAML files define train, val, test, nc, and names.
Important behavior:
scripts/data/split_dataset.pycan automatically rewrite these YAMLs to point to the latest generated split.- This allows notebooks and training commands to remain stable while data versions change.
python3 scripts/minio/download_from_minio.pyDefault destination:
data/raw/minio_full/
Use the curated folders:
data/curated/limpieza_caja/data/curated/limpieza_veta/
Example (default mode is solo_vetas):
python3 scripts/data/split_dataset.py \
--base-dir data/curated/limpieza_veta \
--out-dir data/splits \
--dataset-prefix 2026-03-06 \
--modes solo_vetasGenerate multiple modes in one pass:
python3 scripts/data/split_dataset.py \
--base-dir data/curated/limpieza_veta \
--out-dir data/splits \
--dataset-prefix 2026-03-06 \
--modes solo_cajas solo_vetas mixtoDo not update training YAMLs automatically:
python3 scripts/data/split_dataset.py --no-update-training-configspython3 scripts/data/validate_labels_images.py \
--yaml-path configs/vetas.yaml \
--split trainpython3 scripts/data/remap_labels_to_class0.py \
--labels-dir data/splitsUse:
notebooks/training.ipynb
Notebook sections are ordered to:
- Set environment
- Define shared paths/defaults
- Register utility functions
- Quick GPU cleanup
- Configure one run
- Train
- Validate
- Predict (optional)
Use:
notebooks/export_pt_to_engine.ipynb
This notebook is organized for:
- GPU/CUDA/TensorRT checks
- PT model + YAML config setup
.pt -> .engineexport- Optional sanity inference and speed check
Expected structure:
result/<class>/<split>__<run>/
Where:
<class>:Caja,Vetas,mixed,unclassified<split>: inferred from trainingdatayaml<run>: run folder name
Reorganize legacy runs:
python3 scripts/results/organize_results.py # preview
python3 scripts/results/organize_results.py --apply # apply changesFor split folders:
YYYY-MM-DD_<scope>_vN- Example:
2026-03-06_solo_vetas_v1
For training runs:
<split_tag>__run_XXX- Example:
2026-03-06_solo_vetas_v1__run_001
For result path grouping:
result/Vetas/<split_tag>__run_001result/Caja/<split_tag>__run_001
# Sync env
uv sync
# Build split(s)
python3 scripts/data/split_dataset.py --base-dir data/curated/limpieza_veta --out-dir data/splits --dataset-prefix 2026-03-06 --modes solo_vetas
# Validate split in FiftyOne
python3 scripts/data/validate_labels_images.py --yaml-path configs/vetas.yaml --split val
# Organize results
python3 scripts/results/organize_results.py --apply- Some MinIO scripts currently contain hardcoded endpoint/credentials and absolute paths. Consider moving them to environment variables before production sharing.
- Keep large artifacts (
data/,result/,*.pt,*.engine) out of Git unless strictly needed. - Treat
data/raw/minio_full/as immutable historical source and run curation indata/curated/.
uv sync- Sync/download raw data (if needed)
- Curate data under
data/curated/ - Run
split_dataset.py - Confirm
configs/*.yamlpaths are correct - Train from
notebooks/training.ipynb - Validate and store run in
result/<class>/... - Export to TensorRT if deployment requires
.engine