This Repo contains my scripts for the EEL 6825: Pattern Recogntion Spring 2021 Course.
- Skin lesion classification with ensemble of squeeze-and-excitation networks and semi-supervised learning
- Self-training with Noisy Student improves ImageNet classification
- Bottleneck Transformers for Visual Recognition
- Rotate to Attend: Convolutional Triplet Attention Module
-
☑ Balanced Sampler
-
☑ Mixed Precision
-
☑ Gradient Accumulation
-
☑ Optimum Learning Rate Finder [LR Finder Suggestion is terrible. I just observed the learning rate at which loss starts to diverge and set
learning_rate = learning rate at diverging loss/100
. No particular intention behind it.] -
☑ TTA
- Margin Focal Loss
- APTOS Gold Medal Solutions: Although data type is different but it might be helpful.
- Melanoma Recognition via Visual Attention
- Deep Metric Learning Solution For MVTec Anomaly Detection Dataset
- Ugly Duckling Concept
- Humpback Whale Classification 1st place solution
- Attention model for feature extraction
- Run
git clone https://github.com/tahsin314/Diabetic_Retinopathy-Detection-Pattern-Recognition-Course-Project
- Run
conda env create -f environment.yml
- Run
train.py
. Change parameters according to your preferences from thedr_config.ini
file before training. dr_config
parameters:n_fold = Total number of folds fold = fold that you want to keep as your validation set SEED = Seed value. This value will be use for random initialization batch_size sz = Image Dimension learning_rate patience = patience for Learning Rate Scheduler accum_step = Gradient Accumulation steps num_class = If regression, it should be 1 otherwise 5 gpu_ids = GPUs to use mixed_precision target_type = Regression, Classification or Ordinal Regression pretrained_model = model name model_type = Normal, TripletAttention, CBAttention cam_layer_name = Class Activation Mapping Layer model_dir = Directory where models will be saved distributed_backend = None, dp or ddp. Currently ddp does not work mode = train or lr_finder load_model = 0 if False else 1 imagenet_stats = mean and standard deviation of imagenet data crop = False if 0 i.e, circle crop won't be applied ben_color = Ben Graham's preprocessing technique. True if set to 1 n_epochs = number of epochs to train TTA = Test Time Augmentation balanced_sampler data_dir image_path test_image_path
EfficientNet's are designed to take in to account input image dimensions.
So if you want to squeeze every last droplet from your model make sure to use same image resolutions as described below:
Efficientnet-B0 : 224
Efficientnet-B1 : 240
Efficientnet-B2 : 260
Efficientnet-B3 : 300
Efficientnet-B4 : 380
Efficientnet-B5 : 456
Efficientnet-B6 : 528
Efficientnet-B7 : 600
- Currently muli gpu training only works with
distributed_backend='dp'
. However,Stochastic Weight Averaging
breaks it. distributed_backend='dp'
also fails to gather data from multiple GPUs and returns predictions and labels with shape(batch_num, )
where it is supposed to return data with shape(num_samples, )
(num_samples ≈ num_batches * batch_size
). This is probably a pytorch-lightning bug. It is advised to comment outdistributed_backend='dp'
and training on single GPU at this moment.
Alternative: Try running inference on test data on single GPU or set batch_size=1
during test.
Added an ugly hack for gathering predictions and labels with distributed_backend='dp'
. Now data can be gathered from multiple GPUs. Hope that pytorch-Lightning will fix their gather
issue.