| cancer_detection/ | |
| ├─ CMakeLists.txt | |
| ├─ README_RUN.md | |
| ├─ vendor/ | |
| │ └─ stb_image.h <-- (Debes descargar y colocar este fichero aquí) | |
| ├─ src/ | |
| │ ├─ main.cpp | |
| │ ├─ data_loader.hpp | |
| │ ├─ data_loader.cpp | |
| │ ├─ optical_model.hpp | |
| │ ├─ optical_model.cu | |
| │ ├─ fungi.hpp | |
| │ ├─ fungi.cu | |
| │ ├─ training.hpp | |
| │ ├─ training.cpp | |
| │ └─ utils.hpp | |
| └─ data/ | |
| ├─ train_labels.csv | |
| ├─ train/ | |
| │ ├─ abc...123.tif | |
| │ └─ ... | |
| └─ test/ | |
| ├─ def...456.tif | |
| └─ ... | |
| Aquí tienes el programa completo en C++17/CUDA, diseñado para la competición Histopathologic Cancer Detection de Kaggle. Está totalmente en inglés, optimizado para una RTX 3090, y no utiliza ninguna capa convencional como CNNs o Transformers. | |
| Puntos Clave de la Adaptación | |
| Carga de Datos: El programa utiliza la librería stb_image.h (un solo fichero, sin dependencias) para leer las imágenes TIFF directamente desde el disco. Carga las etiquetas del train_labels.csv y asocia los IDs. | |
| Manejo de Color (RGB): Para mantener la simplicidad y la eficiencia del bloque óptico, las imágenes de 96x96x3 (RGB) se convierten a escala de grises (96x96x1) promediando los canales. Esto enfoca el modelo en la estructura y textura, que son clave en histopatología. | |
| Modelo de Clasificación: La salida es un único logit (un valor real), ya que es una clasificación binaria. Usamos una función de pérdida Binary Cross-Entropy (BCE), que es el estándar para esta tarea. | |
| Sistema Micelar: La población de "hongos" evoluciona para generar las máscaras ópticas de 96x96 que mejor discriminan entre tejido sano y tumoral. La "comida" se asigna en función de cómo cada hongo ayuda a reducir el error de clasificación. | |
| Generación de CSV por Época: Después de cada época de entrenamiento, el programa ejecuta la inferencia sobre todo el conjunto de test y genera un fichero submission_epoch_XX.csv listo para subir a Kaggle. Esto te permite monitorizar el progreso y elegir tu mejor modelo. | |
| 📦 Estructura del Proyecto | |
| code | |
| Code | |
| cancer_detection/ | |
| ├─ CMakeLists.txt | |
| ├─ README_RUN.md | |
| ├─ vendor/ | |
| │ └─ stb_image.h <-- (Debes descargar y colocar este fichero aquí) | |
| ├─ src/ | |
| │ ├─ main.cpp | |
| │ ├─ data_loader.hpp | |
| │ ├─ data_loader.cpp | |
| │ ├─ optical_model.hpp | |
| │ ├─ optical_model.cu | |
| │ ├─ fungi.hpp | |
| │ ├─ fungi.cu | |
| │ ├─ training.hpp | |
| │ ├─ training.cpp | |
| │ └─ utils.hpp | |
| └─ data/ | |
| ├─ train_labels.csv | |
| ├─ train/ | |
| │ ├─ abc...123.tif | |
| │ └─ ... | |
| └─ test/ | |
| ├─ def...456.tif | |
| └─ ... | |
| 🛠️ Build & Run (Instructions in English) | |
| (Contenido del fichero README_RUN.md) | |
| Mycelium-Optical Cancer Detection (C++/CUDA) | |
| This project implements a non-conventional optical/evolutionary model for the Kaggle Histopathologic Cancer Detection competition. | |
| Architecture: | |
| Input: 96x96 RGB images, converted to grayscale. | |
| Optical Block: A population of evolving "fungi" generates 96x96 amplitude and phase masks. | |
| Propagation: 2D FFT propagation using batched cuFFT. | |
| Detector: Intensity |U|^2 -> log1p non-linearity -> single logit output. | |
| Training: Custom backpropagation + Mycelial evolution (reward, gravity, reproduction). | |
| Loss: Binary Cross-Entropy with Logits. | |
| Requirements: | |
| Linux (recommended) or Windows with WSL2. | |
| CUDA Toolkit 11.4+ (optimized for Ampere, e.g., RTX 3090). | |
| A recent CMake (>= 3.18). | |
| Download stb_image.h from the official GitHub repo and place it in the vendor/ directory. | |
| Build: | |
| code | |
| Bash | |
| mkdir build && cd build | |
| cmake -DCMAKE_BUILD_TYPE=Release .. | |
| cmake --build . -j | |
| Run Training & Inference: | |
| Place the Kaggle data in the data/ directory as shown in the project layout. | |
| code | |
| Bash | |
| ./cancer_trainer --data_dir ../data --epochs 50 --batch 256 --lr 1e-3 --fungi 256 | |
| --data_dir: Path to the directory containing train/, test/, and train_labels.csv. | |
| --batch: Adjust based on VRAM. 256 works well on an RTX 3090 (24GB). | |
| --fungi: Number of fungi in the mycelial population. | |
| The program will save submission_epoch_01.csv, submission_epoch_02.csv, etc., in the execution directory after each epoch. |