# ssd_benchmark **Repository Path**: zhao_ting_v/ssd_benchmark ## Basic Information - **Project Name**: ssd_benchmark - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2021-09-08 - **Last Updated**: 2022-07-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## [SSD Description](#contents) SSD discretizes the output space of bounding boxes into a set of default boxes over different aspect ratios and scales per feature map location. At prediction time, the network generates scores for the presence of each object category in each default box and produces adjustments to the box to better match the object shape.Additionally, the network combines predictions from multiple feature maps with different resolutions to naturally handle objects of various sizes. [Paper](https://arxiv.org/abs/1512.02325): Wei Liu, Dragomir Anguelov, Dumitru Erhan, Christian Szegedy, Scott Reed, Cheng-Yang Fu, Alexander C. Berg.European Conference on Computer Vision (ECCV), 2016 (In press). ## [Model Architecture](#contents) The SSD approach is based on a feed-forward convolutional network that produces a fixed-size collection of bounding boxes and scores for the presence of object class instances in those boxes, followed by a non-maximum suppression step to produce the final detections. The early network layers are based on a standard architecture used for high quality image classification, which is called the base network. Then add auxiliary structure to the network to produce detections. ssd_benchmark is based on resnet34 ## [Dataset](#contents) Note that you can run the scripts based on the dataset mentioned in original paper or widely used in relevant domain/network architecture. In the following sections, we will introduce how to run the scripts using the related dataset below. Dataset used: [COCO2017]() - Dataset size:19G - Train:18G,118000 images - Val:1G,5000 images - Annotations:241M,instances,captions,person_keypoints etc - Data format:image and json files - Note:Data will be processed in dataset.py ## [Environment Requirements](#contents) - Install [MindSpore](https://www.mindspore.cn/install/en). - Download the dataset COCO2017. - We use COCO2017 as training dataset in this example by default, and you can also use your own datasets. First, install PyTurboJPEG ,pycocotool and opencv to process data and to get evaluation result. ```shell conda install PyTurboJPEG -c conda-forge conda install opencv-python # install NVIDIA-pycocotools git clone https://github.com/NVIDIA/cocoapi.git cd ./cocoapi/PythonAPI pip install py pybind11 python setup.py build_ext install ``` 1. If coco dataset is used. **Select dataset to coco when run script.** Change the `coco_root` and other settings you need in `model_utils/ssd_xxx.yaml`. The directory structure is as follows: ```shell . └─coco_dataset ├─annotations ├─instance_train2017.json └─instance_val2017.json ├─val2017 └─train2017 ``` 2. If VOC dataset is used. **Select dataset to voc when run script.** Change `classes`, `num_classes`, `voc_json` and `voc_root` in `model_utils/ssd_xxx.yaml`. `voc_json` is the path of json file with coco format for evaluation, `voc_root` is the path of VOC dataset, the directory structure is as follows: ```shell . └─voc_dataset └─train ├─0001.jpg └─0001.xml ... ├─xxxx.jpg └─xxxx.xml └─eval ├─0001.jpg └─0001.xml ... ├─xxxx.jpg └─xxxx.xml ``` 3. If your own dataset is used. **Select dataset to other when run script.** Organize the dataset information into a TXT file, each row in the file is as follows: ```shell train2017/0000001.jpg 0,259,401,459,7 35,28,324,201,2 0,30,59,80,2 ``` Each row is an image annotation which split by space, the first column is a relative path of image, the others are box and class infomations of the format [xmin,ymin,xmax,ymax,class]. We read image from an image path joined by the `image_dir`(dataset directory) and the relative path in `anno_path`(the TXT file path), `image_dir` and `anno_path` are setting in `model_utils/ssd_xxx.yaml`. ## [Quick Start](#contents) ### Prepare the model Convert pytroch resnet34 parameter to MindSpore checkpoint. ### Run the scripts After installing MindSpore via the official website, you can start training: Convert pytorch pth to MindSpore checkpoint, and you will get checkpoint at `src/model_utils/resnet34.ckpt` ```shell bash scripts/get_ckpt.sh ``` Modifying parameter configurations in `./config/config_ssd300.yaml` - running on Ascend ```shell # distributed training on Ascend bash run_distribute_train.sh [DEVICE_NUM] [RANK_TABLE_FILE] [CONFIG_PATH]