Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
DexterJZ 1fb2453afc | 8 months ago | |
---|---|---|
.. | ||
README.md | 8 months ago | |
callbacks.py | 8 months ago | |
create_data.py | 8 months ago | |
data.py | 8 months ago | |
eval.py | 8 months ago | |
model.py | 8 months ago | |
ssd_mobilenetv2.yaml | 8 months ago | |
ssd_mobilenetv2_gpu.yaml | 8 months ago | |
ssd_mobilenetv3.yaml | 8 months ago | |
ssd_mobilenetv3_gpu.yaml | 8 months ago | |
ssd_resnet50_fpn.yaml | 8 months ago | |
ssd_resnet50_fpn_gpu.yaml | 8 months ago | |
train.py | 8 months ago | |
utils.py | 8 months ago |
SSD is an single-staged object detector. It discretizes the output space of bounding boxes into a set of default boxes over different aspect ratios and scales per feature map location, and combines predictions from multi-scale feature maps to detect objects with various sizes. At prediction time, SSD 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.
Figure 1. Architecture of SSD [1]
In this example, by leveraging the multi-scale feature extraction of MindCV, we demonstrate that using backbones from MindCV much simplifies the implementation of SSD.
Here, we provide three configurations of SSD.
We train and test SSD using COCO 2017 Dataset. The dataset contains
git clone https://github.com/mindspore-lab/mindcv.git
Install dependencies as shown here.
Download COCO 2017 Dataset, prepare the dataset as follows.
.
└─cocodataset
├─annotations
├─instance_train2017.json
└─instance_val2017.json
├─val2017
└─train2017
Run the following commands to preprocess the dataset and convert it to MindRecord format for reducing preprocessing time during training and testing.
cd mindcv # change directory to the root of MindCV repository
python examples/det/ssd/create_data.py coco --data_path [root of COCO 2017 Dataset] --out_path [directory for storing MindRecord files]
Specify the path of the preprocessed dataset at keyword data_dir
in the config file.
backbone_ckpt_path
in the config file.MobileNetV2 | ResNet50 | MobileNetV3 |
---|---|---|
backbone weights | backbone weights | backbone weights |
It is highly recommended to use distributed training for this SSD implementation.
For distributed training using OpenMPI's mpirun
, simply run
cd mindcv # change directory to the root of MindCV repository
mpirun -n [# of devices] python examples/det/ssd/train.py --config [the path to the config file]
For example, if train SSD distributively with the MobileNetV2
configuration on 8 devices, run
cd mindcv # change directory to the root of MindCV repository
mpirun -n 8 python examples/det/ssd/train.py --config examples/det/ssd/ssd_mobilenetv2.yaml
For distributed training with Ascend rank table, configure ascend8p.sh
as follows
#!/bin/bash
export DEVICE_NUM=8
export RANK_SIZE=8
export RANK_TABLE_FILE="./hccl_8p_01234567_127.0.0.1.json"
for ((i = 0; i < ${DEVICE_NUM}; i++)); do
export DEVICE_ID=$i
export RANK_ID=$i
echo "Launching rank: ${RANK_ID}, device: ${DEVICE_ID}"
if [ $i -eq 0 ]; then
echo 'i am 0'
python examples/det/ssd/train.py --config [the path to the config file] &> ./train.log &
else
echo 'not 0'
python -u examples/det/ssd/train.py --config [the path to the config file] &> /dev/null &
fi
done
and start training by running
cd mindcv # change directory to the root of MindCV repository
bash ascend8p.sh
For single-device training, please run
cd mindcv # change directory to the root of MindCV repository
python examples/det/ssd/train.py --config [the path to the config file]
For testing the trained model, first specify the path to the model checkpoint at keyword ckpt_path
in the config file, then run
cd mindcv # change directory to the root of MindCV repository
python examples/det/ssd/eval.py --config [the path to the config file]
For example, for testing SSD with the MobileNetV2
configuration, run
cd mindcv # change directory to the root of MindCV repository
python examples/det/ssd/eval.py --config examples/det/ssd/ssd_mobilenetv2.yaml
Here are the performance resutls and the pretrained model weights for each configuration.
Configuration | Mixed Precision | mAP | Config | Download |
---|---|---|---|---|
MobileNetV2 | O2 | 23.2 | yaml | weights |
ResNet50 with FPN | O3 | 38.3 | yaml | weights |
MobileNetV3 | O2 | 23.8 | yaml | weights |
[1] Liu, W., Anguelov, D., Erhan, D., Szegedy, C., Reed, S., Fu, C. Y., & Berg, A. C. (2016). SSD: Single Shot Multibox Detector. In Computer Vision–ECCV 2016: 14th European Conference, Amsterdam, The Netherlands, October 11–14, 2016, Proceedings, Part I 14 (pp. 21-37). Springer International Publishing.
A toolbox of vision models and algorithms based on MindSpore
https://github.com/mindspore-lab/mindcv
Python Markdown other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》