MCPcopy
hub / github.com/hustvl/Vim / test

Method test

det/tests/data/test_coco.py:78–98  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

76
77class TestRLEToJson(unittest.TestCase):
78 def test(self):
79 # Make a dummy dataset.
80 mask = make_mask()
81 DatasetCatalog.register("test_dataset", lambda: make_dataset_dicts(mask))
82 MetadataCatalog.get("test_dataset").set(thing_classes=["test_label"])
83
84 # Dump to json.
85 json_dict = convert_to_coco_dict("test_dataset")
86 with tempfile.TemporaryDirectory() as tmpdir:
87 json_file_name = os.path.join(tmpdir, "test.json")
88 with open(json_file_name, "w") as f:
89 json.dump(json_dict, f)
90 # Load from json.
91 dicts = load_coco_json(json_file_name, "")
92
93 # Check the loaded mask matches the original.
94 anno = dicts[0]["annotations"][0]
95 loaded_mask = mask_util.decode(anno["segmentation"])
96 self.assertTrue(np.array_equal(loaded_mask, mask))
97 DatasetCatalog.pop("test_dataset")
98 MetadataCatalog.pop("test_dataset")
99
100 def test_uncompressed_RLE(self):
101 mask = make_mask()

Callers 2

test_with_TTAMethod · 0.45
mainFunction · 0.45

Calls 8

convert_to_coco_dictFunction · 0.90
load_coco_jsonFunction · 0.90
make_maskFunction · 0.85
make_dataset_dictsFunction · 0.85
dumpMethod · 0.80
registerMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected