File size: 1,647 Bytes
6c9ac8f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
import os.path as osp
import tempfile
import unittest
from mmengine.fileio import dump
from mmdet.datasets.api_wrappers import COCOPanoptic
class TestCOCOPanoptic(unittest.TestCase):
def setUp(self):
self.tmp_dir = tempfile.TemporaryDirectory()
def tearDown(self):
self.tmp_dir.cleanup()
def test_create_index(self):
ann_json = {'test': ['test', 'createIndex']}
annotation_file = osp.join(self.tmp_dir.name, 'createIndex.json')
dump(ann_json, annotation_file)
COCOPanoptic(annotation_file)
def test_load_anns(self):
categories = [{
'id': 0,
'name': 'person',
'supercategory': 'person',
'isthing': 1
}]
images = [{
'id': 0,
'width': 80,
'height': 60,
'file_name': 'fake_name1.jpg',
}]
annotations = [{
'segments_info': [
{
'id': 1,
'category_id': 0,
'area': 400,
'bbox': [10, 10, 10, 40],
'iscrowd': 0
},
],
'file_name':
'fake_name1.png',
'image_id':
0
}]
ann_json = {
'images': images,
'annotations': annotations,
'categories': categories,
}
annotation_file = osp.join(self.tmp_dir.name, 'load_anns.json')
dump(ann_json, annotation_file)
api = COCOPanoptic(annotation_file)
api.load_anns(1)
self.assertIsNone(api.load_anns(0.1))
|