Module Name | faster_rcnn_resnet50_coco2017 |
---|---|
Category | object detection |
Network | faster_rcnn |
Dataset | COCO2017 |
Fine-tuning supported or not | No |
Module Size | 131MB |
Latest update date | 2021-03-15 |
Data indicators | - |
-
- Faster_RCNN is a two-stage detector, it consists of feature extraction, proposal, classification and refinement processes. This module is trained on COCO2017 dataset, and can be used for object detection.
-
-
paddlepaddle >= 1.6.2
-
paddlehub >= 1.6.0 | How to install PaddleHub
-
-
-
$ hub install faster_rcnn_resnet50_coco2017
- In case of any problems during installation, please refer to: Windows_Quickstart | Linux_Quickstart | Mac_Quickstart
-
-
-
$ hub run faster_rcnn_resnet50_coco2017 --input_path "/PATH/TO/IMAGE"
- If you want to call the Hub module through the command line, please refer to: PaddleHub Command Line Instruction
-
-
-
import paddlehub as hub import cv2 object_detector = hub.Module(name="faster_rcnn_resnet50_coco2017") result = object_detector.object_detection(images=[cv2.imread('/PATH/TO/IMAGE')]) # or # result = object_detector.object_detection(paths=['/PATH/TO/IMAGE'])
-
-
-
def object_detection(paths=None, images=None, batch_size=1, use_gpu=False, output_dir='detection_result', score_thresh=0.5, visualization=True)
-
Detection API, detect positions of all objects in image
-
Parameters
- paths (list[str]): image path;
- images (list[numpy.ndarray]): image data, ndarray.shape is in the format [H, W, C], BGR;
- batch_size (int): the size of batch;
- use_gpu (bool): use GPU or not; set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU
- output_dir (str): save path of images;
- score_thresh (float): confidence threshold;
- visualization (bool): Whether to save the results as picture files;
NOTE: choose one parameter to provide data from paths and images
-
Return
- res (list[dict]): results
- data (list): detection results, each element in the list is dict
- confidence (float): the confidence of the result
- label (str): label
- left (int): the upper left corner x coordinate of the detection box
- top (int): the upper left corner y coordinate of the detection box
- right (int): the lower right corner x coordinate of the detection box
- bottom (int): the lower right corner y coordinate of the detection box
- save_path (str, optional): output path for saving results
- data (list): detection results, each element in the list is dict
- res (list[dict]): results
-
-
def save_inference_model(dirname)
-
Save model to specific path
-
Parameters
- dirname: model save path
-
-
-
PaddleHub Serving can deploy an online service of object detection.
-
-
Run the startup command:
-
$ hub serving start -m faster_rcnn_resnet50_coco2017
-
The servitization API is now deployed and the default port number is 8866.
-
NOTE: If GPU is used for prediction, set CUDA_VISIBLE_DEVICES environment variable before the service, otherwise it need not be set.
-
-
-
With a configured server, use the following lines of code to send the prediction request and obtain the result
-
import requests import json import cv2 import base64 def cv2_to_base64(image): data = cv2.imencode('.jpg', image)[1] return base64.b64encode(data.tostring()).decode('utf8') # Send an HTTP request data = {'images':[cv2_to_base64(cv2.imread("/PATH/TO/IMAGE"))]} headers = {"Content-type": "application/json"} url = "http://127.0.0.1:8866/predict/faster_rcnn_resnet50_coco2017" r = requests.post(url=url, headers=headers, data=json.dumps(data)) # print prediction results print(r.json()["results"])
-
-
1.1.0
First release
-
1.1.1
Fix the problem of reading numpy
-
1.2.0
Remove fluid api
-
$ hub install faster_rcnn_resnet50_coco2017==1.2.0
-