移动端对象检测模型,无需GPU https://github.com/google/mediapipe
天问 7b1733cfcc Update 'README.md' | 10 months ago | |
---|---|---|
README.md | 10 months ago |
MediaPipe对象检测模型,可以针对图片,视频或者实时直播视频流进行对象检测任务
pip install mediapipe
import numpy as np
import mediapipe as mp
from mediapipe.tasks import python
from mediapipe.tasks.python import vision
IMAGE_FILE = '12.jpg'
base_options = python.BaseOptions(model_asset_path='efficientdet.tflite')
options = vision.ObjectDetectorOptions(base_options=base_options,score_threshold=0.5)
detector = vision.ObjectDetector.create_from_options(options)
image = mp.Image.create_from_file(IMAGE_FILE)
detection_result = detector.detect(image)
image_copy = np.copy(image.numpy_view())
annotated_image = visualize(image_copy, detection_result)
rgb_annotated_image = cv2.cvtColor(annotated_image, cv2.COLOR_BGR2RGB)
cv2_imshow(rgb_annotated_image)