Created
October 14, 2019 05:35
-
-
Save Tony607/28f40d6208d27554f06bc4afa4e82422 to your computer and use it in GitHub Desktop.
How to train Detectron2 with Custom COCO Datasets | DLology
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from detectron2.utils.visualizer import ColorMode | |
for d in random.sample(dataset_dicts, 3): | |
im = cv2.imread(d["file_name"]) | |
outputs = predictor(im) | |
v = Visualizer(im[:, :, ::-1], | |
metadata=fruits_nuts_metadata, | |
scale=0.8, | |
instance_mode=ColorMode.IMAGE_BW # remove the colors of unsegmented pixels | |
) | |
v = v.draw_instance_predictions(outputs["instances"].to("cpu")) | |
cv2_imshow(v.get_image()[:, :, ::-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment