{"id":22615529,"url":"https://github.com/sovit-123/pytorch-efficientdet-api","last_synced_at":"2026-04-25T16:33:23.302Z","repository":{"id":111787130,"uuid":"450871875","full_name":"sovit-123/pytorch-efficientdet-api","owner":"sovit-123","description":"A PyTorch EfficientDet API for easy training and inference on custom datasets.","archived":false,"fork":false,"pushed_at":"2022-02-27T06:54:42.000Z","size":1165,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T00:42:21.455Z","etag":null,"topics":["deep-learning","deeplearning","efficientdet","efficientnet","object-detection","objectdetection","pytorch"],"latest_commit_sha":null,"homepage":"https://sovit-123.github.io/pytorch-efficientdet-api/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sovit-123.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-22T16:27:35.000Z","updated_at":"2022-08-29T07:16:04.000Z","dependencies_parsed_at":"2023-03-13T13:33:41.947Z","dependency_job_id":null,"html_url":"https://github.com/sovit-123/pytorch-efficientdet-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sovit-123/pytorch-efficientdet-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-efficientdet-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-efficientdet-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-efficientdet-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-efficientdet-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sovit-123","download_url":"https://codeload.github.com/sovit-123/pytorch-efficientdet-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sovit-123%2Fpytorch-efficientdet-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32269458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","deeplearning","efficientdet","efficientnet","object-detection","objectdetection","pytorch"],"created_at":"2024-12-08T19:08:16.105Z","updated_at":"2026-04-25T16:33:23.278Z","avatar_url":"https://github.com/sovit-123.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyTorch EfficientDet API\n\n\nA simple training, testing, and inference pipeline using [Ross Wightman's EfficientDet models](https://github.com/rwightman/efficientdet-pytorch). Ross Wightman's repo is used a submodule to load the EfficientDet models. \n\nThe training/testing/inference code are custom written.\n\nGet started with training within 5 minutes if you have the images and XML annotation files.\n\n\n\n## Get Started with Inference\n\n​\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1-_g9yqE3DA4Q3r2Tw1jRG86SCshIAOx1?usp=sharing) [![Kaggle](https://kaggle.com/static/images/open-in-kaggle.svg)](https://www.kaggle.com/sovitrath/pytorch-efficientdet-api-coco-model-inference)\n\n\n\n## Go To\n\n* [Setup for Ubuntu](#Setup-for-Ubuntu)\n* [Setup on Windows](#Setup-on-Windows)\n* [Train on Custom Dataset](#Train-on-Custom-Dataset)\n* [Inference](#Inference)\n\n\n\n## Setup for Ubuntu\n\n1. Clone the repository.\n\n   ```\n   git clone --recursive https://github.com/sovit-123/pytorch-efficientdet-api.git\n   ```\n\n2. Install requirements.\n\n   1. **Method 1**: If you have CUDA and cuDNN set up already, do this in your environment of choice\n\n      ```\n      pip install -r requirments.txt\n      ```\n\n   2. **Method 2**: If you want to install PyTorch with CUDA Toolkit in your environment of choice.\n\n      ```\n      conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch\n      ```\n\n      OR\n\n      ```\n      conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch\n      ```\n\n      OR install the version with CUDA support as per your choice from **[here](https://pytorch.org/get-started/locally/)**.\n\n      Then install the remaining **[requirements](https://github.com/sovit-123/pytorch-efficientdet-api/blob/main/requirements.txt)**.\n\n\n\n## Setup on Windows\n\n1. **First you need to install Microsoft Visual Studio from [here](https://my.visualstudio.com/Downloads?q=Visual%20Studio%202017)**. Sing In/Sing Up by clicking on **[this link](https://my.visualstudio.com/Downloads?q=Visual%20Studio%202017)** and download the **Visual Studio Community 2017** edition.\n\n   ![](readme_images/vs-2017-annotated.jpg)\n\n   Install with all the default chosen settings. It should be around 6 GB. Mainly, we need the C++ Build Tools.\n\n2. Then install the proper **`pycocotools`** for Windows.\n\n   ```\n   pip install git+https://github.com/gautamchitnis/cocoapi.git@cocodataset-master#subdirectory=PythonAPI\n   ```\n\n3. Clone the repository.\n\n   ```\n   git clone --recursive https://github.com/sovit-123/pytorch-efficientdet-api.git\n   ```\n\n4. Install PyTorch with CUDA support.\n\n   ```\n   conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch\n   ```\n\n   OR\n\n   ```\n   conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch\n   ```\n\n   OR install the version with CUDA support as per your choice from **[here](https://pytorch.org/get-started/locally/)**.\n\n   Then install the remaining **[requirements](https://github.com/sovit-123/pytorch-efficientdet-api/blob/main/requirements.txt)** except for `pycocotools`.\n\n\n\n## Train on Custom Dataset\n\nTaking an exmaple of the [smoke dataset](https://www.kaggle.com/didiruh/smoke-pascal-voc) from Kaggle. Let's say that the dataset is in the `data/smoke_pascal_voc` directory in the following format. And the `smoke.yaml` is in the `data_configs` directory.\n\n```\n├── data\n│   ├── smoke_pascal_voc\n│   │   ├── archive\n│   │   │   ├── train\n│   │   │   └── valid\n│   └── README.md\n├── data_configs\n│   └── smoke.yaml\n├── efficientdet-pytorch\n│   ├── effdet\n│   ...\n├── model_configs\n│   └── model_config.yaml\n├── models\n│   ├── efficientdet_d0.py\n│   ├── efficientdet_model.py\n│   └── tf_efficientdet_lite0.py\n├── outputs\n│   ├── inference\n│   │   ├── res_1\n│   │   └── res_2\n│   └── training\n│       ├── res_1\n│       └── res_2\n├── torch_utils\n│   ├── coco_eval.py\n│   ├── coco_utils.py\n│   ├── engine.py\n│   ├── README.md\n│   └── utils.py\n├── config.py\n├── custom_utils.py\n├── datasets.py\n├── README.md\n├── requirements.txt\n├── test_image.py\n├── test_video.py\n└── train.py\n```\n\nThe content of the `smoke.yaml` should be the following:\n\n```yaml\n# TRAIN_DIR should be relative to train.py\nTRAIN_DIR_IMAGES: data/smoke_pascal_voc/archive/train/images\nTRAIN_DIR_LABELS: data/smoke_pascal_voc/archive/train/annotations\n# VALID_DIR should be relative to train.py\nVALID_DIR_IMAGES: data/smoke_pascal_voc/archive/valid/images\nVALID_DIR_LABELS: data/smoke_pascal_voc/archive/valid/annotations\n# Class names.\nCLASSES: ['smoke']\n# Number of classes.\nNC: 1\n# Whether to save the predictions of the validation set while training.\nSAVE_VALID_PREDICTION_IMAGES: True\n```\n\n***Note that*** *the data and annotations can be in the same directory as well. In that case, the TRAIN_DIR_IMAGES and TRAIN_DIR_LABELS will save the same path. Similarly for VALID images and labels. The `datasets.py` will take care of that*.\n\nNext, to start the training, you can use the following command.\n\n**Command format:**\n\n```\npython train.py --model \u003cname of the model (default tf_efficientdet_lite0)\u003e --config \u003cpath to the data config\u003e --device \u003ccomputation device (default cuda:0 if GPU available system)\u003e --epochs \u003cepochs to train for\u003e --workers \u003cnumber of parallel workers (default 4)\u003e --batch-size \u003cbatch size for data loading (default 8)\u003e  \n```\n\n**In this case, the exact command would be:**\n\n```\npython train.py --model tf_efficientdet_lite0 --config data_configs/smoke.yaml --device cuda:0 --epochs 5 --workers 4 --batch-size 8  \n```\n\n**The terimal output should be similar to the following:**\n\n```\nNumber of training samples: 665\nNumber of validation samples: 72\n\n3,191,405 total parameters.\n3,191,405 training parameters.\nEpoch     0: adjusting learning rate of group 0 to 1.0000e-03.\nEpoch: [0]  [ 0/84]  eta: 0:02:17  lr: 0.000013  loss: 1.6518 (1.6518)  time: 1.6422  data: 0.2176  max mem: 1525\nEpoch: [0]  [83/84]  eta: 0:00:00  lr: 0.001000  loss: 1.6540 (1.8020)  time: 0.0769  data: 0.0077  max mem: 1548\nEpoch: [0] Total time: 0:00:08 (0.0984 s / it)\ncreating index...\nindex created!\nTest:  [0/9]  eta: 0:00:02  model_time: 0.0928 (0.0928)  evaluator_time: 0.0245 (0.0245)  time: 0.2972  data: 0.1534  max mem: 1548\nTest:  [8/9]  eta: 0:00:00  model_time: 0.0318 (0.0933)  evaluator_time: 0.0237 (0.0238)  time: 0.1652  data: 0.0239  max mem: 1548\nTest: Total time: 0:00:01 (0.1691 s / it)\nAveraged stats: model_time: 0.0318 (0.0933)  evaluator_time: 0.0237 (0.0238)\nAccumulating evaluation results...\nDONE (t=0.03s).\nIoU metric: bbox\n Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.001\n Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.002\n Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.000\n Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.000\n Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.001\n Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.009\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.007\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.029\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.074\n Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.028\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.088\n Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.167\nSAVING PLOTS COMPLETE...\n...\nEpoch: [4]  [ 0/84]  eta: 0:00:20  lr: 0.001000  loss: 0.9575 (0.9575)  time: 0.2461  data: 0.1662  max mem: 1548\nEpoch: [4]  [83/84]  eta: 0:00:00  lr: 0.001000  loss: 1.1325 (1.1624)  time: 0.0762  data: 0.0078  max mem: 1548\nEpoch: [4] Total time: 0:00:06 (0.0801 s / it)\ncreating index...\nindex created!\nTest:  [0/9]  eta: 0:00:02  model_time: 0.0369 (0.0369)  evaluator_time: 0.0237 (0.0237)  time: 0.2494  data: 0.1581  max mem: 1548\nTest:  [8/9]  eta: 0:00:00  model_time: 0.0323 (0.0330)  evaluator_time: 0.0226 (0.0227)  time: 0.1076  data: 0.0271  max mem: 1548\nTest: Total time: 0:00:01 (0.1116 s / it)\nAveraged stats: model_time: 0.0323 (0.0330)  evaluator_time: 0.0226 (0.0227)\nAccumulating evaluation results...\nDONE (t=0.03s).\nIoU metric: bbox\n Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.137\n Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.313\n Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.118\n Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.029\n Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.175\n Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.428\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.204\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.306\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.347\n Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.140\n Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.424\n Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.683\nSAVING PLOTS COMPLETE...\n```\n\n\n\n## Inference\n\n### Inference on Images using Pretrained Models\n\nUse the **[efficientdet-pytorch](https://github.com/rwightman/efficientdet-pytorch)** models trained on the COCO dataset.\n\n**Command format:**\n\n```\npython test_image.py --input \u003cpath/to/input/image\u003e --model \u003cmodel_name\u003e\n```\n\n**Example:**\n\n```\npython test_image.py --input data/inference_data/image_1.jpg --model tf_efficientdet_lite0\n```\n\n### Inference on Images using Custom Trained Model\n\nUse your custom trained model to run inference on any image. Providing path to config file is mandatory here to get class information\n\n**Command format:**\n\n```\npython test_image.py --input \u003cpath/to/input/image\u003e --model \u003cmodel_name\u003e --weights \u003cpath/to/saved_model_weights\u003e --config \u003cpath/to/config file\u003e\n```\n\n**Example:**\n\n```\npython test_image.py --input data/inference_data/image_1.jpg --model tf_efficientdet_lite0 --weights outputs/training/res_19/last_model_state.pth --config data_configs/smoke.yaml\n```\n\n### Inference on Videos using Pretrained Models\n\n**Command format:**\n\n```\npython test_video.py --input \u003cpath/to/input/video\u003e --model \u003cmodel_name\u003e\n```\n\n**Example:**\n\n```\npython test_video.py --input data/inference_data/video_2.mp4 --model tf_efficientdet_lite0\n```\n\n### Inference on Videos using Custom Trained Models\n\n**Command format:**\n\n```\npython test_video.py --input \u003cpath/to/input/video\u003e --model \u003cmodel_name\u003e --weights \u003cpath/to/saved_model_weights\u003e --config \u003cpath/to/config file\u003e\n```\n\n**Example:**\n\n```\npython test_video.py --input data/inference_data/video_3.mp4 --model tf_efficientdet_lite0 --weights outputs/training/res_19/last_model_state.pth --config data_configs/smoke.yaml\n```\n\n### \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovit-123%2Fpytorch-efficientdet-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsovit-123%2Fpytorch-efficientdet-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovit-123%2Fpytorch-efficientdet-api/lists"}