I created a custom COCO dataset. Now suppose I have valid image metadata in image_data
. I can display the image and the annotation with
import skimage.io as io
import matplotlib.pyplot as plt
image_directory ='my_images/'
image = io.imread(image_directory + image_data['file_name'])
plt.imshow(image); plt.axis('off')
pylab.rcParams['figure.figsize'] = (8.0, 10.0)
annotation_ids = example_coco.getAnnIds(imgIds=image_data['id'], catIds=category_ids, iscrowd=None)
annotations = example_coco.loadAnns(annotation_ids)
example_coco.showAnns(annotations)
At this point, I'll be able to see annotations overlaid over the image. However, I want to save the image with the annotations overlaid on top of it. How can I do that? I tried
io.imsave(fname="test.png", arr=image)
But it doesn't work. It just saves the original image, without any annotation.