PaddleHub可以便捷地获取PaddlePaddle生态下的预训练模型,完成模型的管理和一键预测。配合使用Fine-tune API,可以基于大规模预训练模型快速完成迁移学习,让预训练模型能更好地服务于用户特定场景的应用。
模型概述:
模型概述
Faster_RCNN是两阶段目标检测器。通过对图像生成候选区域,提取特征,判别特征类别并修正候选框位置。Faster_RCNN整体网络可以分为4个主要内容,一是ResNet-50作为基础卷积层,二是区域生成网络,三是Rol Align,四是检测层。Faster_RCNN是在MS-COCO数据集上预训练的模型。该PaddleHub Module可支持预测。
代码及效果示例:
import paddlehub as hub
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
#faster_rcnn_coco2017
module = hub.Module(name="faster_rcnn_coco2017")
test_img_path = "./body2.jpg"
# 预测结果展示
img = mpimg.imread(test_img_path)
plt.imshow(img)
plt.axis('off')
plt.show()
# set input dict
input_dict = {"image": [test_img_path]}
# execute predict and print the result
results = module.object_detection(data=input_dict)
for result in results:
print(result)
test_img_path = "./output/body2.jpg"
img = mpimg.imread(test_img_path)
plt.imshow(img)
plt.axis('off')
plt.show()
[2020-01-08 06:54:40,430] [ INFO] - Installing faster_rcnn_coco2017 module
2020-01-08 06:54:40,430-INFO: Installing faster_rcnn_coco2017 module
[2020-01-08 06:54:40,462] [ INFO] - Module faster_rcnn_coco2017 already installed in /home/aistudio/.paddlehub/modules/faster_rcnn_coco2017
2020-01-08 06:54:40,462-INF