labelme_draw_json 628 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python
  2. import argparse
  3. import json
  4. import matplotlib.pyplot as plt
  5. from labelme import utils
  6. def main():
  7. parser = argparse.ArgumentParser()
  8. parser.add_argument('json_file')
  9. args = parser.parse_args()
  10. json_file = args.json_file
  11. data = json.load(open(json_file))
  12. img = utils.img_b64_to_array(data['imageData'])
  13. lbl, lbl_names = utils.labelme_shapes_to_label(img.shape, data['shapes'])
  14. lbl_viz = utils.draw_label(lbl, img, lbl_names)
  15. plt.subplot(121)
  16. plt.imshow(img)
  17. plt.subplot(122)
  18. plt.imshow(lbl_viz)
  19. plt.show()
  20. if __name__ == '__main__':
  21. main()