Răsfoiți Sursa

Add coco det data

Bobholamovic 2 ani în urmă
părinte
comite
45fa7a5b14

+ 1 - 0
paddlers/transforms/operators.py

@@ -122,6 +122,7 @@ class Transform(object):
 class DecodeImg(Transform):
     """
     Decode image(s) in input.
+    
     Args:
         to_rgb (bool, optional): If True, convert input images from BGR format to RGB format. Defaults to True.
     """

+ 18 - 1
tests/data/data_utils.py

@@ -17,7 +17,7 @@ import re
 import imghdr
 import platform
 from collections import OrderedDict
-from functools import partial
+from functools import partial, wraps
 
 import numpy as np
 
@@ -53,6 +53,22 @@ def get_full_path(p, prefix=''):
     return osp.join(prefix, p)
 
 
+def silent(func):
+    def _do_nothing(*args, **kwargs):
+        pass
+
+    @wraps(func)
+    def _wrapper(*args, **kwargs):
+        import builtins
+        print = builtins.print
+        builtins.print = _do_nothing
+        ret = func(*args, **kwargs)
+        builtins.print = print
+        return ret
+
+    return _wrapper
+
+
 class ConstrSample(object):
     def __init__(self, prefix, label_list):
         super().__init__()
@@ -235,6 +251,7 @@ class ConstrDetSample(ConstrSample):
         self.ct += 1
         return {'image': im_path, ** im_info, ** label_info}
 
+    @silent
     def _parse_coco_files(self, im_dir, ann_path):
         from pycocotools.coco import COCO
 

+ 106 - 0
tests/data/ssst/det_gt_coco.json

@@ -0,0 +1,106 @@
+{
+    "images": [
+        {
+            "height": 256,
+            "width": 256,
+            "id": 1,
+            "file_name": "optical.bmp"
+        },  
+        {
+            "height": 256,
+            "width": 256,
+            "id": 2,
+            "file_name": "sar.tiff"
+        },  
+        {
+            "height": 256,
+            "width": 256,
+            "id": 3,
+            "file_name": "multispectral.tif"
+        }
+    ],
+    "categories": [
+        {
+            "supercategory": "component",
+            "id": 1,
+            "name": "target"
+        }
+    ],
+    "annotations": [
+        {
+            "segmentation": [
+                [
+                    28,
+                    89,
+                    28,
+                    253,
+                    72,
+                    253,
+                    72,
+                    89
+                ]
+            ],
+            "iscrowd": 0,
+            "image_id": 1,
+            "bbox": [
+                28.0,
+                89.0,
+                44.0,
+                164.0
+            ],
+            "area": 7216.0,
+            "category_id": 1,
+            "id": 1
+        },
+        {
+            "segmentation": [
+                [
+                    28,
+                    89,
+                    28,
+                    253,
+                    72,
+                    253,
+                    72,
+                    89
+                ]
+            ],
+            "iscrowd": 0,
+            "image_id": 2,
+            "bbox": [
+                28.0,
+                89.0,
+                44.0,
+                164.0
+            ],
+            "area": 7216.0,
+            "category_id": 1,
+            "id": 2
+        },
+        {
+            "segmentation": [
+                [
+                    28,
+                    89,
+                    28,
+                    253,
+                    72,
+                    253,
+                    72,
+                    89
+                ]
+            ],
+            "iscrowd": 0,
+            "image_id": 3,
+            "bbox": [
+                28.0,
+                89.0,
+                44.0,
+                164.0
+            ],
+            "area": 7216.0,
+            "category_id": 1,
+            "id": 3
+        }
+    ]
+}

+ 0 - 0
tests/data/ssst/det_gt.xml → tests/data/ssst/det_gt_voc.xml


+ 1 - 0
tests/data/ssst/test_det_coco.txt

@@ -0,0 +1 @@
+./ det_gt_coco.json

+ 3 - 3
tests/data/ssst/test_mixed_det.txt

@@ -1,3 +1,3 @@
-optical.bmp det_gt.xml
-sar.tiff det_gt.xml
-multispectral.tif det_gt.xml
+optical.bmp det_gt_voc.xml
+sar.tiff det_gt_voc.xml
+multispectral.tif det_gt_voc.xml

+ 1 - 1
tests/data/ssst/test_multispectral_det.txt

@@ -1 +1 @@
-multispectral.tif det_gt.xml
+multispectral.tif det_gt_voc.xml

+ 1 - 1
tests/data/ssst/test_optical_det.txt

@@ -1 +1 @@
-optical.bmp det_gt.xml
+optical.bmp det_gt_voc.xml

+ 1 - 1
tests/data/ssst/test_sar_det.txt

@@ -1 +1 @@
-sar.tiff det_gt.xml
+sar.tiff det_gt_voc.xml

+ 4 - 1
tests/transforms/test_operators.py

@@ -38,7 +38,7 @@ def _add_op_tests(cls):
             attr_name = 'test_' + op_name
             if hasattr(cls, attr_name):
                 continue
-            # If the operator cannot be initialized with default parameters, skip it
+            # If the operator cannot be initialized with default parameters, skip it.
             for key, param in inspect.signature(
                     op_class.__init__).parameters.items():
                 if key == 'self':
@@ -165,6 +165,9 @@ class TestTransform(CpuCommonTest):
                 'data/ssst/test_multispectral_det.txt',
                 prefix='./data/ssst',
                 label_list='data/ssst/labels_det.txt'), 
+            build_input_from_file(
+                'data/ssst/test_det_coco.txt',
+                prefix='./data/ssst'), 
             build_input_from_file(
                 'data/ssmt/test_mixed_binary.txt',
                 prefix='./data/ssmt'),