百度AI攻略:Paddlehub實現目標檢測
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-INFO: Module faster_rcnn_coco2017 already installed in /home/aistudio/.paddlehub/modules/faster_rcnn_coco2017
[2020-01-08 06:54:40,984] [ INFO] - 169 pretrained paramaters loaded by PaddleHub
2020-01-08 06:54:40,984-INFO: 169 pretrained paramaters loaded by PaddleHub
image with bbox drawed saved as /home/aistudio/work/output/body2.jpg
{'path': './body2.jpg', 'data': [{'left': 89.073586, 'right': 331.32816, 'top': 50.749474, 'bottom': 277.31653, 'label': 'person', 'confidence': 0.9966834}]}
In[6]
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 = "./body1.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/body1.jpg"
img = mpimg.imread(test_img_path)
plt.imshow(img)
plt.axis('off')
plt.show()
[2020-01-08 06:55:16,472] [ INFO] - Installing faster_rcnn_coco2017 module
2020-01-08 06:55:16,472-INFO: Installing faster_rcnn_coco2017 module
[2020-01-08 06:55:16,483] [ INFO] - Module faster_rcnn_coco2017 already installed in /home/aistudio/.paddlehub/modules/faster_rcnn_coco2017
2020-01-08 06:55:16,483-INFO: Module faster_rcnn_coco2017 already installed in /home/aistudio/.paddlehub/modules/faster_rcnn_coco2017
[2020-01-08 06:55:17,044] [ INFO] - 169 pretrained paramaters loaded by PaddleHub
2020-01-08 06:55:17,044-INFO: 169 pretrained paramaters loaded by PaddleHub
image with bbox drawed saved as /home/aistudio/work/output/body1.jpg
{'path': './body1.jpg', 'data': [{'left': 333.45242, 'right': 802.91956, 'top': 318.4439, 'bottom': 1052.2673, 'label': 'person', 'confidence': 0.7535156}, {'left': 209.79471, 'right': 795.71326, 'top': 319.2016, 'bottom': 1515.5725, 'label': 'person', 'confidence': 0.99797016}, {'left': 723.31616, 'right': 1350.0393, 'top': 217.41296, 'bottom': 1949.7135, 'label': 'person', 'confidence': 0.9976978}, {'left': 264.5524, 'right': 828.4072, 'top': 852.47485, 'bottom': 2025.8547, 'label': 'person', 'confidence': 0.84229875}, {'left': 734.1046, 'right': 1297.6768, 'top': 236.46027, 'bottom': 1131.4011, 'label': 'person', 'confidence': 0.99232954}, {'left': 736.2953, 'right': 1197.4048, 'top': 893.317, 'bottom': 2082.668, 'label': 'person', 'confidence': 0.74164623}, {'left': 1153.4473, 'right': 1451.6208, 'top': 1204.4583, 'bottom': 1735.3435, 'label': 'handbag', 'confidence': 0.6623996}]}
In[7]
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 = "./vehicle1.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/vehicle1.jpg"
img = mpimg.imread(test_img_path)
plt.imshow(img)
plt.axis('off')
plt.show()
[2020-01-08 06:55:41,351] [ INFO] - Installing faster_rcnn_coco2017 module
2020-01-08 06:55:41,351-INFO: Installing faster_rcnn_coco2017 module
[2020-01-08 06:55:41,362] [ INFO] - Module faster_rcnn_coco2017 already installed in /home/aistudio/.paddlehub/modules/faster_rcnn_coco2017
2020-01-08 06:55:41,362-INFO: Module faster_rcnn_coco2017 already installed in /home/aistudio/.paddlehub/modules/faster_rcnn_coco2017
[2020-01-08 06:55:41,753] [ INFO] - 169 pretrained paramaters loaded by PaddleHub
2020-01-08 06:55:41,753-INFO: 169 pretrained paramaters loaded by PaddleHub
image with bbox drawed saved as /home/aistudio/work/output/vehicle1.jpg
{'path': './vehicle1.jpg', 'data': [{'left': 172.94551, 'right': 587.33716, 'top': 164.10345, 'bottom': 380.49017, 'label': 'car', 'confidence': 0.99788874}]}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69922494/viewspace-2673936/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 百度AI攻略:Paddlehub實現影像分割AI
- AI攻略:Paddlehub實現人體解析AI
- [AI開發]目標檢測之素材標註AI
- 目標檢測
- 使用SlimYOLOv3框架實現實時目標檢測YOLO框架
- 2018目標檢測
- 九、目標檢測
- 混合高斯模型實現運動目標檢測(OpenCV內建實現)模型OpenCV
- 【目標檢測】Fast R-CNN演算法實現ASTCNN演算法
- pytorch實現yolov3(5) 實現端到端的目標檢測PyTorchYOLO
- 目標檢測之SSD
- 目標檢測之RetinaNetNaN
- 目標檢測面面觀
- 28-目標檢測
- 目標檢測綜述
- 使用 YOLO 進行實時目標檢測YOLO
- 目標檢測:二維碼檢測方案
- Python+OpenCV目標跟蹤實現基本的運動檢測PythonOpenCV
- 使用Harr特徵的級聯分類器實現目標檢測特徵
- 目標檢測---教你利用yolov5訓練自己的目標檢測模型YOLO模型
- 目標檢測之YOLO系列YOLO
- 【目標檢測】Bounding Box Regression
- 目標檢測發展方向
- SSD 目標檢測 Keras 版Keras
- 【目標檢測】R-CNNCNN
- 做目標檢測,這一篇就夠了!2019最全目標檢測指南
- 深度學習之目標檢測與目標識別深度學習
- TF專案實戰(基於SSD目標檢測)——人臉檢測1
- 【百度飛漿】YOLO系列目標檢測演算法詳解YOLO演算法
- 目標檢測實用中可以改進的方向
- 目標檢測入門系列手冊七:目標檢測的產品應用實踐【工業視覺篇】視覺
- Object Detection(目標檢測神文)Object
- 目標檢測(Object Detection)總覽Object
- 2019 年的目標檢測指南
- 目標檢測相關論文
- 目標檢測:Segmentation is All You Need ?Segmentation
- 深度學習之目標檢測深度學習
- 目標檢測(一):LeNet-5