Skip to content

Instantly share code, notes, and snippets.

@Praveen76
Created July 29, 2020 05:26
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 Praveen76/d918368878842367bdf965fe021ff5ab to your computer and use it in GitHub Desktop.
Save Praveen76/d918368878842367bdf965fe021ff5ab to your computer and use it in GitHub Desktop.
# pick a random image
filepath = df.sample()['fileName'].values[0]
# get all rows for this image
df2 = df[df['fileName'] == filepath]
im = np.array(Image.open(filepath))
# if there's a PNG it will have alpha channel
im = im[:,:,:3]
for idx, row in df2.iterrows():
box = [
row['xmin'],
row['ymin'],
row['xmax'],
row['ymax'],
]
print(box)
draw_box(im, box, color=(255, 0, 0))
plt.axis('off')
plt.imshow(im)
plt.show()
show_image_with_boxes(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment