{"id":27860637,"url":"https://github.com/vietnh1009/ssd-pytorch","last_synced_at":"2025-10-10T04:43:26.107Z","repository":{"id":41520420,"uuid":"337563322","full_name":"vietnh1009/SSD-pytorch","owner":"vietnh1009","description":"SSD: Single Shot MultiBox Detector pytorch implementation focusing on simplicity","archived":false,"fork":false,"pushed_at":"2021-02-10T18:52:38.000Z","size":98746,"stargazers_count":169,"open_issues_count":4,"forks_count":48,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-10-02T15:17:11.082Z","etag":null,"topics":["computer-vision","deep-learning","deep-neural-networks","deeplearning","detection","detector","neural-networks","object-detection","pytorch","ssd","ssdlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vietnh1009.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-09T23:19:59.000Z","updated_at":"2025-09-09T12:49:23.000Z","dependencies_parsed_at":"2022-07-07T18:21:01.302Z","dependency_job_id":null,"html_url":"https://github.com/vietnh1009/SSD-pytorch","commit_stats":null,"previous_names":["vietnh1009/ssd-pytorch","uvipen/ssd-pytorch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vietnh1009/SSD-pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FSSD-pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FSSD-pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FSSD-pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FSSD-pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vietnh1009","download_url":"https://codeload.github.com/vietnh1009/SSD-pytorch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FSSD-pytorch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002670,"owners_count":26083442,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["computer-vision","deep-learning","deep-neural-networks","deeplearning","detection","detector","neural-networks","object-detection","pytorch","ssd","ssdlite"],"created_at":"2025-05-04T17:43:58.394Z","updated_at":"2025-10-10T04:43:26.102Z","avatar_url":"https://github.com/vietnh1009.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SSD: Single Shot MultiBox Detector\n\n## Introduction\n\nHere is my pytorch implementation of 2 models: **SSD-Resnet50** and **SSDLite-MobilenetV2**. These models are based on original model (SSD-VGG16) described in the paper [SSD: Single Shot MultiBox Detector](https://arxiv.org/pdf/1512.02325). **This implementation supports mixed precision training**.\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"demo/video.gif\"\u003e\u003cbr/\u003e\n  \u003ci\u003eAn example of SSD Resnet50's output.\u003c/i\u003e\n\u003c/p\u003e\n\n## Motivation\n\nWhy this implementation exists while there are many ssd implementations already ?\n\nI believe that many of you when seeing this implementation have this question in your mind. Indeed there are already many implementations for SSD and its variants in Pytorch. However most of them are either: \n- over-complicated\n- modularized\n- many improvements added\n- not evaluated/visualized\n\nThe above-mentioned points make learner hard to understand how original ssd looks like. Hence, I re-implement this well-known model, focusing on simplicity. I believe this implementation is suitable for ML/DL users from different levels, especially beginners. In compared to model described in the paper, there are some minor changes (e.g. backbone), but other parts follow paper strictly.  \n\n## Datasets\n\n\n| Dataset                | Classes |    #Train images      |    #Validation images      |\n|------------------------|:---------:|:-----------------------:|:----------------------------:|\n| COCO2017               |    80   |          118k         |              5k            |\n\n  \n- **COCO**:\n  Download the coco images and annotations from [coco website](http://cocodataset.org/#download). Make sure to put the files as the following structure (The root folder names **coco**):\n  ```\n  coco\n  ├── annotations\n  │   ├── instances_train2017.json\n  │   └── instances_val2017.json\n  │── train2017\n  └── val2017 \n  ```\n## Docker\n\nFor being convenient, I provide Dockerfile which could be used for running training as well as test phases\n\nAssume that docker image's name is **ssd**. You already created an empty folder name **trained_models** for storing trained weights. Then you clone this repository and cd into it.\n\nBuild:\n\n`docker build --network=host -t ssd .`\n\nRun:\n\n`docker run --rm -it -v path/to/your/coco:/coco -v path/to/trained_models:/trained_models --ipc=host --network=host ssd`\n\n## How to use my code\n\nAssume that at this step, you either already installed necessary libraries or you are inside docker container\n\nNow, with my code, you can:\n\n* **Train your model** by running `python -m torch.distributed.launch --nproc_per_node=NUM_GPUS_YOU_HAVE train.py --model [ssd|ssdlite] --batch-size [int] [--amp]`. You could stop or resume your training process whenever you want. For example, if you stop your training process after 10 epochs, the next time you run the training script, your training process will continue from epoch 10. mAP evaluation, by default, will be run at the end of each epoch. **Note**: By specifying **--amp** flag, your model will be trained with mixed precision (FP32 and FP16) instead of full precision (FP32) by default. Mixed precision training reduces gpu usage and therefore allows you train your model with bigger batch size while sacrificing negligible accuracy. More infomation could be found at [apex](https://github.com/NVIDIA/apex) and [pytorch](https://pytorch.org/docs/stable/notes/amp_examples.html).\n* **Test your model for COCO dataset** by running `python test_dataset.py --pretrained_model path/to/trained_model`\n* **Test your model for image** by running `python test_image.py --pretrained_model path/to/trained_model --input path/to/input/file --output path/to/output/file`\n* **Test your model for video** by running `python test_video.py --pretrained_model path/to/trained_model --input path/to/input/file --output path/to/output/file`\n\nYou could download my trained weight for SSD-Resnet50 at [link](https://drive.google.com/drive/folders/1_DYYDJUfwLIvGBDnM3hMFNgkVRZW6MgX?usp=sharing)\n## Experiments\n\nI trained my models by using NVIDIA RTX 2080. Below is mAP evaluation for **SSD-Resnet50** trained for 54 epochs on **COCO val2017** dataset \n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"demo/mAP.png\"\u003e\u003cbr/\u003e\n  \u003ci\u003eSSD-Resnet50 evaluation.\u003c/i\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"demo/tensorboard.png\"\u003e\u003cbr/\u003e\n  \u003ci\u003eSSD-Resnet50 tensorboard for training loss curve and validation mAP curve.\u003c/i\u003e\n\u003c/p\u003e\n\n## Results\n\nSome predictions are shown below:\n\n\u003cimg src=\"demo/1.jpg\" width=\"250\"\u003e \u003cimg src=\"demo/2.jpg\" width=\"250\"\u003e \u003cimg src=\"demo/3.jpg\" width=\"250\"\u003e\n\n\u003cimg src=\"demo/4.jpg\" width=\"250\"\u003e \u003cimg src=\"demo/5.jpg\" width=\"250\"\u003e \u003cimg src=\"demo/6.jpg\" width=\"250\"\u003e\n\n\u003cimg src=\"demo/7.jpg\" width=\"250\"\u003e \u003cimg src=\"demo/8.jpg\" width=\"250\"\u003e \u003cimg src=\"demo/9.jpg\" width=\"250\"\u003e\n\n\n## References\n- Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, Alexander C. Berg \"SSD: Single Shot MultiBox Detector\" [SSD: Single Shot MultiBox Detector](https://arxiv.org/abs/1512.02325).\n\n- My implementation is inspired by and therefore borrows many parts from [NVIDIA Deep Learning examples](https://github.com/NVIDIA/DeepLearningExamples/tree/master/PyTorch/Detection/SSD) and [ssd pytorch](https://github.com/qfgaohao/pytorch-ssd)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvietnh1009%2Fssd-pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvietnh1009%2Fssd-pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvietnh1009%2Fssd-pytorch/lists"}