test_utils.py 417 B

123456789101112131415161718
  1. import json
  2. import os.path as osp
  3. import numpy as np
  4. from labelme import utils
  5. here = osp.dirname(osp.abspath(__file__))
  6. def test_img_b64_to_array():
  7. json_file = osp.join(here, '../examples/single_image/apc2016_obj3.json')
  8. data = json.load(open(json_file))
  9. img_b64 = data['imageData']
  10. img = utils.img_b64_to_array(img_b64)
  11. assert img.dtype == np.uint8
  12. assert img.shape == (907, 1210, 3)