A pure Tensorflow+Keras Implementation of SSD (Single Shot MultiBox Detector) using different backbones of Efficientnet on the PASCAL_VOC dataset.
- Python 3.6+
- Tensorflow 2.2.0 (For GPU, use Tensorflow-GPU 2.2.0)
- Tensorflow_Datasets 3.0.0+
- Efficientnet
To install these dependencies for CPU, run
pip install -r requirements.txt
(For GPU support, change line tensorflow==2.2.0
to tensorflow-gpu==2.2.0
in requirements.txt)
Add your images to the inputs/
folder and then run
python predict.py
A pretrained model with EfficientNetB0 backbone will load and run on all images in the inputs/
folder. The results can be found in the outputs/
folder.
To train or evaluate the model would require downloading the PASCAL VOC dataset and converting it into tfrecords format by tensorflow_datasets
module. This is done automatically in train.py
or eval.py
but requires a considerable amount of time on the first run.
In eval.py
, change the checkpoint_filepath
variable to your trained model weights and make sure the base model i.e. MODEL_NAME
is set according to your architecture ('B0', 'B1'...etc.). Then run
python eval.py
PASCAL_VOC evaluation will be performed on the VOC2007 test dataset.
To train from scratch, run
python train.py
If you want to continue training from a checkpoint set checkpoint_filepath
and set base_lr
accordingly.
Backbone | mAP | Model Size |
---|---|---|
VGG16 | 77.2 | ~200 MB |
Backbone | mAP | Model Size | Download weights |
---|---|---|---|
EfficientNet-B0 | 74.3 | 24MB | model |
EfficientNet-B3 | 76.3 | 49MB | model |
EfficientNet-B5 | 77.5 | 117MB | model |
****************************************************************************************************
Average Precisions
{'aeroplane': 0.7800157231291908,
'bicycle': 0.830080097782427,
'bird': 0.6972303731738765,
'boat': 0.6874695492244346,
'bottle': 0.44450301285192956,
'bus': 0.7784750741179701,
'car': 0.8118978656479396,
'cat': 0.8710704906835629,
'chair': 0.6031652990795755,
'cow': 0.7280159632333296,
'diningtable': 0.7498881454649887,
'dog': 0.8379743383251255,
'horse': 0.8337120771431471,
'motorbike': 0.8194014393196231,
'person': 0.774534918174515,
'pottedplant': 0.5322147125048592,
'sheep': 0.7044521803545073,
'sofa': 0.7880689464995533,
'train': 0.8751272977754305,
'tvmonitor': 0.7190302090784884}
****************************************************************************************************
Mean Average Precision: 0.7433163856782238
****************************************************************************************************
Average Precisions
{'aeroplane': 0.8138464069658522,
'bicycle': 0.8495817279095099,
'bird': 0.7411210589421086,
'boat': 0.6953653156671167,
'bottle': 0.44501229699670486,
'bus': 0.8169842240921157,
'car': 0.8348353061776034,
'cat': 0.867478526227363,
'chair': 0.6359432618499943,
'cow': 0.7347537326752558,
'diningtable': 0.7556188461308526,
'dog': 0.8453690345281261,
'horse': 0.8431191113749101,
'motorbike': 0.8414147988740155,
'person': 0.8000506418143006,
'pottedplant': 0.5718438091150522,
'sheep': 0.7248609390832621,
'sofa': 0.8101149566442967,
'train': 0.8836348165299509,
'tvmonitor': 0.7443892209541666}
****************************************************************************************************
Mean Average Precision: 0.762766901627628
****************************************************************************************************
Average Precisions
{'aeroplane': 0.8402582577317493,
'bicycle': 0.8611873325373057,
'bird': 0.7579335634733774,
'boat': 0.7394833127167081,
'bottle': 0.47933192495395077,
'bus': 0.8181464002356922,
'car': 0.8443131628054835,
'cat': 0.8799997608338624,
'chair': 0.6257301589722992,
'cow': 0.7870176718398668,
'diningtable': 0.7662971953267264,
'dog': 0.8378183820936017,
'horse': 0.8493214449256444,
'motorbike': 0.8534871863365513,
'person': 0.8214934259604633,
'pottedplant': 0.5706558290952545,
'sheep': 0.7471660716329726,
'sofa': 0.7908692690722835,
'train': 0.8834500074371311,
'tvmonitor': 0.7397631809290843}
****************************************************************************************************
Mean Average Precision: 0.7746861769455005
If you find this repo useful in your work and build something interesting, do cite to let me know about it!
@software{swapnil_gupta_2021_4775343,
author = {Swapnil Gupta},
title = {SSD implementation in Keras with EfficientNet},
month = may,
year = 2021,
publisher = {Zenodo},
version = {1.1},
doi = {10.5281/zenodo.4775343},
url = {https://doi.org/10.5281/zenodo.4775343}
}