From 6cba36d6d26f3eb755df61c0c078e81ba4ac29ad Mon Sep 17 00:00:00 2001 From: "rick.chan" Date: Wed, 16 Jun 2021 09:23:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BF=AE=E6=AD=A3=E5=86=85?= =?UTF-8?q?=E5=AE=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: rick.chan --- .../Applications/Caffe/Caffe_SSD_目标检测.md | 62 ++++++++++++++++--- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/Software/Applications/Caffe/Caffe_SSD_目标检测.md b/Software/Applications/Caffe/Caffe_SSD_目标检测.md index 2287f8e..5df07c9 100644 --- a/Software/Applications/Caffe/Caffe_SSD_目标检测.md +++ b/Software/Applications/Caffe/Caffe_SSD_目标检测.md @@ -14,7 +14,14 @@ git checkout ssd ``` -2. Build the code. Please follow Caffe instruction to install all necessary packages and build it. +2. 修改 Makefile 文件: + + ```Makefile + -LIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_hl hdf5 + +LIBRARIES += glog gflags protobuf boost_system boost_filesystem boost_regex m hdf5_serial_hl hdf5_serial + ``` + +3. Build the code. Please follow Caffe instruction to install all necessary packages and build it. ```bash # Modify Makefile.config according to your Caffe installation. @@ -55,11 +62,52 @@ tar -xvf VOCtest_06-Nov-2007.tar ``` -3. Create the LMDB file. +3. 修改 data/VOC0712/create_list.sh 文件: + + ```bash + -root_dir=$HOME/data/VOCdevkit/ + +root_dir=/mnt/workspace/caffe/VOC/VOCdevkit/ + ``` + +4. 修改 data/VOC0712/create_data.sh 文件: + + ```bash + -data_root_dir="$HOME/data/VOCdevkit" + +data_root_dir="/mnt/workspace/caffe/VOC/VOCdevkit" + ``` + +5. Create the LMDB file. + + ```bash + cd $CAFFE_ROOT + # Create the trainval.txt, test.txt, and test_name_size.txt in data/VOC0712/ + ./data/VOC0712/create_list.sh + # You can modify the parameters in create_data.sh if needed. + # It will create lmdb files for trainval and test with encoded original image: + # - $HOME/data/VOCdevkit/VOC0712/lmdb/VOC0712_trainval_lmdb + # - $HOME/data/VOCdevkit/VOC0712/lmdb/VOC0712_test_lmdb + # and make soft links at examples/VOC0712/ + ./data/VOC0712/create_data.sh + ``` ## 3.Train/Eval -1. Train your model and evaluate the model on the fly. +1. 修改 examples/ssd/ssd_pascal.py 文件: + + ```python + -if num_gpus > 0: + - batch_size_per_device = int(math.ceil(float(batch_size) / num_gpus)) + - iter_size = int(math.ceil(float(accum_batch_size) / (batch_size_per_device * num_gpus))) + - solver_mode = P.Solver.GPU + - device_id = int(gpulist[0]) + +#if num_gpus > 0: + +# batch_size_per_device = int(math.ceil(float(batch_size) / num_gpus)) + +# iter_size = int(math.ceil(float(accum_batch_size) / (batch_size_per_device * num_gpus))) + +# solver_mode = P.Solver.GPU + +# device_id = int(gpulist[0]) + ``` + +2. Train your model and evaluate the model on the fly. ```bash # It will create model definition files and save snapshot models in: @@ -74,14 +122,14 @@ If you don't have time to train your model, you can download a pre-trained model at [here](https://drive.google.com/open?id=0BzKzrI_SkD1_WVVTSmQxU0dVRzA). -2. Evaluate the most recent snapshot. +3. Evaluate the most recent snapshot. ```bash # If you would like to test a model you trained, you can do: python examples/ssd/score_ssd_pascal.py ``` -3. Test your model using a webcam. Note: press "esc" to stop. +4. Test your model using a webcam. Note: press "esc" to stop. ```bash # If you would like to attach a webcam to a model you trained, you can do: @@ -90,8 +138,8 @@ [Here](https://drive.google.com/file/d/0BzKzrI_SkD1_R09NcjM1eElLcWc/view) is a demo video of running a SSD500 model trained on [MSCOCO](http://mscoco.org/) dataset. -4. Check out [examples/ssd_detect.ipynb](https://hub.fastgit.org/weiliu89/caffe/blob/ssd/examples/ssd_detect.ipynb) or [examples/ssd/ssd_detect.cpp](https://hub.fastgit.org/weiliu89/caffe/blob/ssd/examples/ssd/ssd_detect.cpp) on how to detect objects using a SSD model. Check out [examples/ssd/plot_detections.py](https://hub.fastgit.org/weiliu89/caffe/blob/ssd/examples/ssd/plot_detections.py) on how to plot detection results output by ssd_detect.cpp. -5. To train on other dataset, please refer to data/OTHERDATASET for more details. We currently add support for COCO and ILSVRC2016. We recommend using [examples/ssd.ipynb](https://hub.fastgit.org/weiliu89/caffe/blob/ssd/examples/ssd_detect.ipynb) to check whether the new dataset is prepared correctly. +5. Check out [examples/ssd_detect.ipynb](https://hub.fastgit.org/weiliu89/caffe/blob/ssd/examples/ssd_detect.ipynb) or [examples/ssd/ssd_detect.cpp](https://hub.fastgit.org/weiliu89/caffe/blob/ssd/examples/ssd/ssd_detect.cpp) on how to detect objects using a SSD model. Check out [examples/ssd/plot_detections.py](https://hub.fastgit.org/weiliu89/caffe/blob/ssd/examples/ssd/plot_detections.py) on how to plot detection results output by ssd_detect.cpp. +6. To train on other dataset, please refer to data/OTHERDATASET for more details. We currently add support for COCO and ILSVRC2016. We recommend using [examples/ssd.ipynb](https://hub.fastgit.org/weiliu89/caffe/blob/ssd/examples/ssd_detect.ipynb) to check whether the new dataset is prepared correctly. ## 4.Models