Untitled
unknown
plain_text
4 years ago
1.1 kB
9
Indexable
# pred
import mrcnn
import mrcnn.config
import mrcnn.model
import mrcnn.visualize
import cv2
import os
CLASS_NAMES = ['BG', 'box']
class SimpleConfig(mrcnn.config.Config):
NAME = "coco_inference"
GPU_COUNT = 1
IMAGES_PER_GPU = 1
NUM_CLASSES = len(CLASS_NAMES)
model = mrcnn.model.MaskRCNN(mode="inference",
config=SimpleConfig(),
model_dir=os.getcwd())
model.load_weights(filepath="/mnt/CAPOOM_STORAGE/Scenes/Floor_plan/Render/floplan.h5",
by_name=True)
image = cv2.imread("/mnt/CAPOOM_STORAGE/Scenes/Floor_plan/Render/floor/combined/00000.png")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
r = model.detect([image], verbose=0)
r = r[0]
mrcnn.visualize.display_instances(image=image,
boxes=r['rois'],
masks=r['masks'],
class_ids=r['class_ids'],
class_names=CLASS_NAMES,
scores=r['scores'])Editor is loading...