Created
February 17, 2020 21:15
-
-
Save curiousily/074d22837c279153754856615237b640 to your computer and use it in GitHub Desktop.
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
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