Skip to content

Instantly share code, notes, and snippets.

@Tony607
Created October 14, 2019 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tony607/28f40d6208d27554f06bc4afa4e82422 to your computer and use it in GitHub Desktop.
Save Tony607/28f40d6208d27554f06bc4afa4e82422 to your computer and use it in GitHub Desktop.
How to train Detectron2 with Custom COCO Datasets | DLology
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