目标检测实战教程04-目标检测实战全流程

01下载套件

!git clone https://gitee.com/paddlepaddle/PaddleDetection.git -b release/2.4

02安装依赖环境

%cd PaddleDetection/
!pip install -r requirements.txt
%cd ..

03解压数据集

!unzip -oq /home/aistudio/data/data121670/Big.zip -d /home/aistudio/data

04修改配置文件

修改训练参数

05训练

!python /home/aistudio/PaddleDetection/tools/train.py \
	-c /home/aistudio/PaddleDetection/configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.yml

06模型评估

评价训练好的模型在测试集的识别效果

!python -u /home/aistudio/PaddleDetection/tools/eval.py \
	-c /home/aistudio/PaddleDetection/configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.yml \
	-o weights=/home/aistudio/output/cascade_rcnn_r50_fpn_1x_coco/model_final

07推理

!python /home/aistudio/PaddleDetection/tools/infer.py \
	-c /home/aistudio/PaddleDetection/configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.yml \
	--draw_threshold=0.7 \
	--infer_dir=test \
	--output_dir=toolinfer \
	--use_vdl=True \
	--save_txt=True \
	-o weights=/home/aistudio/output/cascade_rcnn_r50_fpn_1x_coco/model_final.pdparams

08导出模型

训练导出的模型包含前向传播和后向传播两个过程,而部署推理只需要前向传播的推理过程,所以将训练好的模型进行处理然后导出。

!python -u /home/aistudio/PaddleDetection/tools/export_model.py \
	-c /home/aistudio/PaddleDetection/configs/cascade_rcnn/cascade_rcnn_r50_fpn_1x_coco.yml \
	--output_dir=/home/aistudio/inference_model \
	-o weights=/home/aistudio/output/cascade_rcnn_r50_fpn_1x_coco/model_final

09python推理部署

使用导出后模型完成推理任务。

!python /home/aistudio/PaddleDetection/deploy/python/infer.py \
	--model_dir=/home/aistudio/inference_model/cascade_rcnn_r50_fpn_1x_coco \
	--image_dir=/home/aistudio/test \
	--output_dir=/home/aistudio/zhengshi \
	--device=GPU \
	--threshold=0.5

你可能感兴趣的:(目标检测,目标检测,深度学习,人工智能)