如果我想在Mask RCNN中仅覆盖人体对象,我应该怎么做?

2024-04-19 22:40:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在运行Mask R-CNN。我只想识别人类物体,然后只覆盖人类物体

所以我试着删除在coco文件中学习到的80个对象,但它们不能正常工作。我尝试使用person对象的索引号,但没有成功

class_names = [
    'BG', 'person',
    'bicycle', 'car', 'motorcycle', 'airplane',
    'bus', 'train', 'truck', 'boat', 'traffic light',
    'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird',
    'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear',
    'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie',
    'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball',
    'kite', 'baseball bat', 'baseball glove', 'skateboard',
    'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup',
    'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple',
    'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza',
    'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed',
    'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote',
    'keyboard', 'cell phone', 'microwave', 'oven', 'toaster',
    'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors',
    'teddy bear', 'hair drier', 'toothbrush'
]


 def apply_mask(image, mask, color, alpha=1):    #alpha값 0.5->1
    """apply mask to image"""
    for n, c in enumerate(color):
          image[:, :, n] = np.where(
                mask == 1,
               image[:, :, n] *(1 - alpha) + alpha * c,
               image[:, :, n]
            )

    return image

即使我修改了代码,程序也会继续识别非人类对象


Tags: 对象imagealphamask人类cnncolor物体