Classifying pancreatic adenocarcinoma (PAAD) from histology slides is hard — limited labeled data, high class imbalance, and no clear winner between CNN and transformer architectures for this domain. This repo benchmarks ResNet50 against a Vision Transformer (ViT) on real PAAD histopathology images to find out which generalizes better under those constraints.
The ResNet50 trainer lives in ResNet50/raj_data_paad/. It uses class-balanced loss, early stopping, and learning rate scheduling. The best model is exported to ONNX and TorchScript.
Configure paths and hyperparameters in config.json, then run:
cd ResNet50/raj_data_paad
uv run train_classify.pyThe ViT trainer is in ViT/. It defaults to CPU-optimized settings (70 threads) but works on GPU too.
cd ViT
uv run train_raj_vit.py --epochs 8 --batch_size 16 --output_dir modelsOverride defaults as needed:
uv run train_raj_vit.py --epochs 20 --patience 5 --cpu_threads 72 --num_workers 20CPU:
uv sync --project pyproject_cpu.tomlGPU (CUDA):
uv sync --project pyproject_gpu.tomlRequires Python 3.10+.