Skip to content

Instantly share code, notes, and snippets.

@curiousily
Created February 17, 2020 21:15
Show Gist options
  • Save curiousily/074d22837c279153754856615237b640 to your computer and use it in GitHub Desktop.
Save curiousily/074d22837c279153754856615237b640 to your computer and use it in GitHub Desktop.
os.makedirs("annotated_results", exist_ok=True)
test_image_paths = test_df.file_name.unique()
for clothing_image in test_image_paths:
file_path = f'{IMAGES_PATH}/{clothing_image}'
im = cv2.imread(file_path)
outputs = predictor(im)
v = Visualizer(
im[:, :, ::-1],
metadata=statement_metadata,
scale=1.,
instance_mode=ColorMode.IMAGE
)
instances = outputs["instances"].to("cpu")
instances.remove('pred_masks')
v = v.draw_instance_predictions(instances)
result = v.get_image()[:, :, ::-1]
file_name = ntpath.basename(clothing_image)
write_res = cv2.imwrite(f'annotated_results/{file_name}', result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment