test_shape.py 719 B

1234567891011121314151617181920212223
  1. from .util import get_img_and_data
  2. from labelme.utils import shape as shape_module
  3. def test_shapes_to_label():
  4. img, data = get_img_and_data()
  5. label_name_to_value = {}
  6. for shape in data['shapes']:
  7. label_name = shape['label']
  8. label_value = len(label_name_to_value)
  9. label_name_to_value[label_name] = label_value
  10. cls = shape_module.shapes_to_label(
  11. img.shape, data['shapes'], label_name_to_value)
  12. assert cls.shape == img.shape[:2]
  13. def test_shape_to_mask():
  14. img, data = get_img_and_data()
  15. for shape in data['shapes']:
  16. points = shape['points']
  17. mask = shape_module.shape_to_mask(img.shape[:2], points)
  18. assert mask.shape == img.shape[:2]