Kaggle Dog v.s. Cat competition
- Model: ResNet50
- Train & Validation ratio: 0.85: 0.15
- Performance
- accuracy: 99.25%
- recall: 99.04%
- precision: 99.46%
- auc: 99.97%
- Environment:
Linux
- Python version:
3.10.12
- GPU:
V100, 16G
- Create virtualenv
python -m venv cat_dog_env source cat_dog_env/bin/activate
- Install dependencies
pip install -r requirements.txt
-
Train: Train image classifier.
python tools/train.py --config_file ${config_file} \ --exp_name ${exp_name} \ --img_dir ${img_dir} --test_ratio ${test_ratio} \ --bs ${batch_size} \ --lr ${lr} \ --weight_decay ${weight_decay} \ --weight ${weight} [--adam] \ [--adamw]
config_file
: Training configuration file. File contains model confiiguration, training strategy, etc. Configuration files are inconfigs/
folder.exp_name
: The name of current experiemnt. Training aritfacts (model weights, ROC graph, confusion matrix graph, performance report, etc) will be save incheckpoints/{exp_name}
folder.img_dir
: Folder containing all training images.test_ratio
: Validation set ratio.bs
: Training batch size.lr
: Learning rate.adam
: Use Adam optimizer during training.adamw
: Use AdamW optimizer during training.weight_decay
: Weight_decay regularization.weights
: Pretained model weight path.
-
Inference: Predict image categories in the folder.
python tools/inference.py --config_file ${config_file} \ --img_dir ${img_dir} \ --bs ${batch_size} \ --weight ${weight} \ --save_path ${save_path}
config_file
: Configuration file for inference.img_dir
: Folder containing all images to be predicted.bs
: Inference batch size.weight
: Pretained model weight path.save_path
: Prediction result will save to this file.
-
Evaluate: Evaluate the model performance.
python tools/evaluate.py --config_file ${config_file} \ --csv_path ${csv_path} \ --img_dir ${img_dir} \ --bs ${batch_size} \ --weight ${weight} \ --save_path ${save_path}
config_file
: Configuration file for evaluation.csv_path
: csv file containing testing image names and labels. csv_file should containname
(image name) &label
(image category) columns. Exampleimg_dir
: Folder containing all images to be predicted.bs
: Inference batch size.weight
: Pretained model weight path.save_dir
: Path to save evaluation artifacts, including ROC graph, confusion matrix graph.
- Resnet50: link
- Convnext
- Swin Transformer
- BEITv2