def test_create_dataset(): annotations_path = BASE_PATH / 'new_coco.json' ds = CocoDataset(annotations_path) cat_id = ds.add_category('dog', 'animal') img_id = ds.add_image((BASE_PATH / 'test_nodamage.jpg').as_posix()) ds.add_annotation(img_id, cat_id, [1, 2, 3, 4, 5], 10, [0, 0, 256, 256], 0) assert len(ds) == 1 assert len(ds.anns) == 1 ds.dump() assert annotations_path.exists() with open(annotations_path, 'r') as f: assert len(f.readline()) > 0 os.remove(annotations_path)
def test_create_dataset(): annotations_path = BASE_PATH / "new_coco.json" ds = CocoDataset(annotations_path) cat_id = ds.add_category("dog", "animal") img_id = ds.add_image((BASE_PATH / "test_nodamage.jpg").as_posix(), 100, 100) ds.add_annotation(img_id, cat_id, [1, 2, 3, 4, 5], 10, [0, 0, 256, 256], 0) assert len(ds) == 1 assert len(ds.anns) == 1 ds.dump() assert annotations_path.exists() with open(annotations_path, "r") as f: assert len(f.readline()) > 0 os.remove(annotations_path)