# -*- coding: UTF-8 -*-
## https://github.com/matterport/Mask_RCNN
## https://github.com/matterport/Mask_RCNN/releases/download/v2.0/mask_rcnn_coco.h5
from mrcnn.config import Config
from mrcnn import model as modellib
from mrcnn import visualize
import numpy as np
import colorsys
import imutils
import random
import cv2
import os
model_path = "mask_rcnn_coco.h5"
labels_path = "coco_labels.txt"
image_path = "image.jpg"
# 读取标签
CLASS_NAMES = open(labels_path, encoding="utf-8").read().strip().split("\n")
print(CLASS_NAMES)
# 标签设置颜色
hsv = [(i / len(CLASS_NAMES), 1, 1.0) for i in range(len(CLASS_NAMES))]
COLORS = list(map(lambda c: colorsys.hsv_to_rgb(*c), hsv))
random.seed(42)
random.shuffle(COLORS)
# 配置
class SimpleConfig(Config):
NAME = "coco_inference"
GPU_COUNT = 1
IMAGES_PER_GPU = 1
NUM_CLASSES = len(CLASS_NAMES)
config
图片检测(Mask RCNN)
最新推荐文章于 2022-09-24 21:52:03 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)