Package: torch-ssd
High quality, fast, modular reference implementation of SSD in PyTorch 1.0This repository implementsSSD (Single Shot MultiBox Detector). The implementation is heavily influenced by the projectsssd.pytorch,pytorch-ssdandmaskrcnn-benchmark. This repository aims to be the code base for researches based on SSD.Example SSD output (ssd300_voc0712).LossesLearning rateMetricsHighlightsPyTorch 1.0: Support PyTorch 1.0 or higher.Multi-GPU training and inference: We useDistributedDataParallel, you can train or test with arbitrary GPU(s), the training schema will change accordingly.Modular: And you own modules without pain. We abstractbackbone,Detector,BoxHead,BoxPredictor, etc. You can replace every component with your own code without change the code base. For example, You can addEfficientNetas backbone, just addefficient_net.py(ALREADY ADDED) and register it, specific it in the config file, It's done!CPU support for inference: runs on CPU in inference time.Smooth and enjoyable training procedure: we save the state of model, optimizer, scheduler, training iter, you can stop your training and resume training exactly from the save point without change your trainingCMD.Batched inference: can perform inference using multiple images per batch per GPU.Evaluating during training: eval you model everyeval_stepto check performance improving or not.Metrics Visualization: visualize metrics details in tensorboard, like AP, APl, APm and APs for COCO dataset or mAP and 20 categories' AP for VOC dataset.Auto download: load pre-trained weights from URL and cache it.InstallationRequirementsPython3PyTorch 1.0 or higheryacsVizerGCC >= 4.9OpenCVStep-by-step installationgitclonehttps://github.com/lufficc/SSD.gitcdSSD#Required packagespipinstalltorchtorchvisionyacstqdmopencv-pythonvizer# Optional packages# If you want visualize loss curve. Default is enabled. Disable by using --use_tensorboard 0 when training.pipinstalltensorboardX# If you train coco dataset, must install cocoapi.cd~/github
gitclonehttps://github.com/cocodataset/cocoapi.gitcdcocoapi/PythonAPI
pythonsetup.pybuild_extinstallBuildNMS build is not necessary, as we provide a python-like nms, but is very slower than build-version.# For faster inference you need to build nms, this is needed when evaluating. Only training doesn't need this.cdext
pythonbuild.pybuild_extdevelopTrainSetting Up DatasetsPascal VOCFor Pascal VOC dataset, make the folder structure like this:VOC_ROOT
|__ VOC2007
    |_ JPEGImages
    |_ Annotations
    |_ ImageSets
    |_ SegmentationClass
|__ VOC2012
    |_ JPEGImages
    |_ Annotations
    |_ ImageSets
    |_ SegmentationClass
|__ ...WhereVOC_ROOTdefault isdatasetsfolder in current project, you can create symlinks todatasetsorexport VOC_ROOT="/path/to/voc_root".COCOFor COCO dataset, make the folder structure like this:COCO_ROOT
|__ annotations
    |_ instances_valminusminival2014.json
    |_ instances_minival2014.json
    |_ instances_train2014.json
    |_ instances_val2014.json
    |_ ...
|__ train2014
    |_ <im-1-name>.jpg
    |_ ...
    |_ <im-N-name>.jpg
|__ val2014
    |_ <im-1-name>.jpg
    |_ ...
    |_ <im-N-name>.jpg
|__ ...WhereCOCO_ROOTdefault isdatasetsfolder in current project, you can create symlinks todatasetsorexport COCO_ROOT="/path/to/coco_root".Single GPU training# for example, train SSD300:pythontrain.py--config-fileconfigs/vgg_ssd300_voc0712.yamlMulti-GPU training# for example, train SSD300 with 4 GPUs:exportNGPUS=4python-mtorch.distributed.launch--nproc_per_node=$NGPUStrain.py--config-fileconfigs/vgg_ssd300_voc0712.yamlSOLVER.WARMUP_FACTOR0.03333SOLVER.WARMUP_ITERS1000The configuration files that I provide assume that we are running on single GPU. When changing number of GPUs, hyper-parameter (lr, max_iter, ...) will also changed according to this paper:Accurate, Large Minibatch SGD: Training ImageNet in 1 Hour.EvaluateSingle GPU evaluating# for example, evaluate SSD300:pythontest.py--config-fileconfigs/vgg_ssd300_voc0712.yamlMulti-GPU evaluating# for example, evaluate SSD300 with 4 GPUs:exportNGPUS=4python-mtorch.distributed.launch--nproc_per_node=$NGPUStest.py--config-fileconfigs/vgg_ssd300_voc0712.yamlDemoPredicting image in a folder is simple:pythondemo.py--config-fileconfigs/vgg_ssd300_voc0712.yaml--images_dirdemoThen the predicted images with boxes, scores and label names will saved todemo/resultfolder.MODEL ZOOOrigin Paper:VOC2007 testcoco test-dev2015SSD300*77.225.1SSD512*79.828.8COCO:BackboneInput Sizebox APModel SizeDownloadVGG1630025.2262MBmodelVGG16512xx.xxxx.xMBMobilenet V2320xx.xxxx.xMBPASCAL VOC:BackboneInput SizemAPModel SizeDownloadVGG1630077.6201MBmodelVGG16512xx.xxxx.xMBMobilenet V232068.825.5MBmodelEfficientNet-B330073.997.1MBmodelTroubleshootingIf you have issues running or compiling this code, we have compiled a list of common issues inTROUBLESHOOTING.md. If your issue is not present there, please feel free to open a new issue.