test_utils.py 448 B

12345678910111213141516171819
  1. import json
  2. import os.path as osp
  3. import nose
  4. import numpy as np
  5. from labelme import utils
  6. here = osp.dirname(osp.abspath(__file__))
  7. def test_img_b64_to_array():
  8. json_file = osp.join(here, '../_static/apc2016_obj3.json')
  9. data = json.load(open(json_file))
  10. img_b64 = data['imageData']
  11. img = utils.img_b64_to_array(img_b64)
  12. nose.tools.assert_equal(img.dtype, np.uint8)
  13. nose.tools.assert_equal(img.shape, (3024, 4032, 3))