Implementation of ResNet: Deep Residual Learning for Image Recognition. Give us a star if you like this repo.
Slide to tell how did we analyze and implement Resnet: Click here
Authors:
- Github: dark-kazansky, bdghuy, hoangcaobao, hoangduc199891, sonnymetvn
- Email: [email protected], [email protected], [email protected], [email protected], [email protected]
Advisors:
- Github: bangoc123
- Email: [email protected]
-
Step 1: Make sure you have installed conda like miniConda or Anaconda.
-
Step 2: from your terminal
cd
into Resnet folder thenpython conda env create -f environment.yml
- Option 1: Run
data.py
to download cat&dog data set - Option 2: Set up custom data set
python folderStructure.py
and follow the instruction to create some custom data folders. Then, copy your images to these folders.
Training script:
python train.py --train-folder ${train_folder} --valid-folder ${valid_folder} --num-classes ${num_classes} --epochs ${epochs}
Example:
python train.py --model 'resnet34' --epochs 120 --num-classes 2 --train-folder $train_folder --valid-folder $valid_folder
There are some important arguments for the script you should consider when running it:
train-folder
: The folder of training datavalid-folder
: The folder of validation data- ...
python predict.py --test-data ${link_to_test_data}
Your implementation
Epoch 00189: val_accuracy did not improve from 0.87700
Epoch 190/200
32/32 [==============================] - 55s 2s/step - loss: 0.0667 - accuracy: 0.9770 - val_loss: 0.8112 - val_accuracy: 0.8360
Epoch 00190: val_accuracy did not improve from 0.87700
Epoch 191/200
32/32 [==============================] - 55s 2s/step - loss: 0.0517 - accuracy: 0.9800 - val_loss: 0.7989 - val_accuracy: 0.8460
Epoch 00191: val_accuracy did not improve from 0.87700
Epoch 192/200
32/32 [==============================] - 54s 2s/step - loss: 0.0486 - accuracy: 0.9845 - val_loss: 0.6213 - val_accuracy: 0.8630
Epoch 00192: val_accuracy did not improve from 0.87700
Epoch 193/200
32/32 [==============================] - 55s 2s/step - loss: 0.0464 - accuracy: 0.9835 - val_loss: 0.5506 - val_accuracy: 0.8450
Epoch 00193: val_accuracy did not improve from 0.87700
Epoch 194/200
32/32 [==============================] - 55s 2s/step - loss: 0.0471 - accuracy: 0.9835 - val_loss: 1.0926 - val_accuracy: 0.8220
Epoch 00194: val_accuracy did not improve from 0.87700
Epoch 195/200
32/32 [==============================] - 55s 2s/step - loss: 0.0713 - accuracy: 0.9770 - val_loss: 1.0000 - val_accuracy: 0.8200
Epoch 00195: val_accuracy did not improve from 0.87700
Epoch 196/200
32/32 [==============================] - 55s 2s/step - loss: 0.0512 - accuracy: 0.9835 - val_loss: 1.9371 - val_accuracy: 0.6830
Epoch 00196: val_accuracy did not improve from 0.87700
Epoch 197/200
32/32 [==============================] - 55s 2s/step - loss: 0.0575 - accuracy: 0.9805 - val_loss: 1.1376 - val_accuracy: 0.7760
Epoch 00197: val_accuracy did not improve from 0.87700
Epoch 198/200
32/32 [==============================] - 55s 2s/step - loss: 0.0484 - accuracy: 0.9825 - val_loss: 0.6597 - val_accuracy: 0.8590
Epoch 00198: val_accuracy did not improve from 0.87700
Epoch 199/200
32/32 [==============================] - 55s 2s/step - loss: 0.0712 - accuracy: 0.9720 - val_loss: 1.4779 - val_accuracy: 0.8010
Epoch 00199: val_accuracy did not improve from 0.87700
Epoch 200/200
32/32 [==============================] - 55s 2s/step - loss: 0.0484 - accuracy: 0.9825 - val_loss: 0.6597 - val_accuracy: 0.8590
Epoch 00200: val_accuracy did not improve from 0.87700
The best_model.h5
of resnet50 is too large to commit on github so you can download it here. Then copy to the base folder to load model.
In the ./ResNet
folder, please run: predict.py --test-image "image-path"
to process.
This is some results from us when we test for some regular dog or cat pictures: