Skip to content

Commit

Permalink
Format code (#10512)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaAndroid committed Jun 15, 2023
1 parent 30d195c commit f741c35
Show file tree
Hide file tree
Showing 20 changed files with 136 additions and 146 deletions.
2 changes: 1 addition & 1 deletion configs/_base_/datasets/ade20k_panoptic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

test_pipeline = [
dict(type='LoadImageFromFile', backend_args=backend_args),
dict(type='Resize', scale=(640, 640), keep_ratio=True),
dict(type='Resize', scale=(2560, 640), keep_ratio=True),
dict(type='LoadPanopticAnnotations', backend_args=backend_args),
dict(
type='PackDetInputs',
Expand Down
8 changes: 4 additions & 4 deletions configs/_base_/datasets/ade20k_semantic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dataset_type = 'ADE20KSegDataset'
data_root = 'data/ade/ADEChallengeData2016'
data_root = 'data/ADEChallengeData2016/'

# Example to use different file client
# Method 1: simply set the data root and let the file I/O module
Expand All @@ -26,14 +26,14 @@
with_seg=True,
reduce_zero_label=True),
dict(
type='PackDetInputs',
meta_keys=('img_path', 'ori_shape', 'img_shape', 'text'))
type='PackDetInputs', meta_keys=('img_path', 'ori_shape', 'img_shape'))
]

val_dataloader = dict(
batch_size=1,
num_workers=4,
num_workers=2,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
Expand Down
2 changes: 1 addition & 1 deletion configs/_base_/datasets/refcoco+.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
backend_args = None

test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadImageFromFile', backend_args=backend_args),
dict(type='Resize', scale=(1333, 800), keep_ratio=True),
dict(
type='LoadAnnotations',
Expand Down
2 changes: 1 addition & 1 deletion configs/_base_/datasets/refcoco.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
backend_args = None

test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadImageFromFile', backend_args=backend_args),
dict(type='Resize', scale=(1333, 800), keep_ratio=True),
dict(
type='LoadAnnotations',
Expand Down
2 changes: 1 addition & 1 deletion configs/_base_/datasets/refcocog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
backend_args = None

test_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadImageFromFile', backend_args=backend_args),
dict(type='Resize', scale=(1333, 800), keep_ratio=True),
dict(
type='LoadAnnotations',
Expand Down
1 change: 0 additions & 1 deletion docs/en/user_guides/dataset_prepare.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ Then move the annotations to the `data/ADEChallengeData2016` directory and run t
```shell
mv data/annotations_instance data/ADEChallengeData2016/
mv data/categoryMapping.txt data/ADEChallengeData2016/
mv data/objectInfo150.txt data/ADEChallengeData2016/
mv data/imgCatIds.json data/ADEChallengeData2016/
python tools/dataset_converters/ade20k2coco.py data/ADEChallengeData2016 --task panoptic
python tools/dataset_converters/ade20k2coco.py data/ADEChallengeData2016 --task instance
Expand Down
8 changes: 4 additions & 4 deletions mmdet/datasets/ade20k.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class ADE20KPanopticDataset(CocoPanopticDataset):
'book', 'bench', 'countertop', 'stove', 'palm, palm tree',
'kitchen island', 'computer', 'swivel chair', 'boat',
'arcade machine', 'bus', 'towel', 'light', 'truck', 'chandelier',
'awning, sunshade, sunblind', 'street lamp', 'booth', 'tv', 'airplane',
'clothes', 'pole',
'awning, sunshade, sunblind', 'street lamp', 'booth', 'tv',
'airplane', 'clothes', 'pole',
'bannister, banister, balustrade, balusters, handrail',
'ottoman, pouf, pouffe, puff, hassock', 'bottle', 'van', 'ship',
'fountain', 'washer, automatic washer, washing machine',
Expand Down Expand Up @@ -105,8 +105,8 @@ class ADE20KPanopticDataset(CocoPanopticDataset):
'book', 'bench', 'countertop', 'stove', 'palm, palm tree',
'kitchen island', 'computer', 'swivel chair', 'boat',
'arcade machine', 'bus', 'towel', 'light', 'truck', 'chandelier',
'awning, sunshade, sunblind', 'street lamp', 'booth', 'tv', 'airplane',
'clothes', 'pole',
'awning, sunshade, sunblind', 'street lamp', 'booth', 'tv',
'airplane', 'clothes', 'pole',
'bannister, banister, balustrade, balusters, handrail',
'ottoman, pouf, pouffe, puff, hassock', 'bottle', 'van', 'ship',
'fountain', 'washer, automatic washer, washing machine',
Expand Down
90 changes: 45 additions & 45 deletions mmdet/datasets/coco_semantic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright [c] OpenMMLab. All rights reserved.
# Copyright (c) OpenMMLab. All rights reserved.
from mmdet.registry import DATASETS
from .ade20k import ADE20KSegDataset

Expand Down Expand Up @@ -44,47 +44,47 @@ class CocoSegDataset(ADE20KSegDataset):
'wall-concrete', 'wall-other', 'wall-panel', 'wall-stone',
'wall-tile', 'wall-wood', 'water-other', 'waterdrops',
'window-blind', 'window-other', 'wood'),
palette=[[120, 120, 120], [180, 120, 120], [6, 230, 230], [80, 50, 50],
[4, 200, 3], [120, 120, 80], [140, 140, 140], [204, 5, 255],
[230, 230, 230], [4, 250, 7], [224, 5, 255], [235, 255, 7],
[150, 5, 61], [120, 120, 70], [8, 255, 51], [255, 6, 82],
[143, 255, 140], [204, 255, 4], [255, 51, 7], [204, 70, 3],
[0, 102, 200], [61, 230, 250], [255, 6, 51], [11, 102, 255],
[255, 7, 71], [255, 9, 224], [9, 7, 230], [220, 220, 220],
[255, 9, 92], [112, 9, 255], [8, 255, 214], [7, 255, 224],
[255, 184, 6], [10, 255, 71], [255, 41, 10], [7, 255, 255],
[224, 255, 8], [102, 8, 255], [255, 61, 6], [255, 194, 7],
[255, 122, 8], [0, 255, 20], [255, 8, 41], [255, 5, 153],
[6, 51, 255], [235, 12, 255], [160, 150, 20], [0, 163, 255],
[140, 140, 140], [250, 10, 15], [20, 255, 0], [31, 255, 0],
[255, 31, 0], [255, 224, 0], [153, 255, 0], [0, 0, 255],
[255, 71, 0], [0, 235, 255], [0, 173, 255], [31, 0, 255],
[11, 200, 200], [255, 82, 0], [0, 255, 245], [0, 61, 255],
[0, 255, 112], [0, 255, 133], [255, 0, 0], [255, 163, 0],
[255, 102, 0], [194, 255, 0], [0, 143, 255], [51, 255, 0],
[0, 82, 255], [0, 255, 41], [0, 255, 173], [10, 0, 255],
[173, 255, 0], [0, 255, 153], [255, 92, 0], [255, 0, 255],
[255, 0, 245], [255, 0, 102], [255, 173, 0], [255, 0, 20],
[255, 184, 184], [0, 31, 255], [0, 255, 61], [0, 71, 255],
[255, 0, 204], [0, 255, 194], [0, 255, 82], [0, 10, 255],
[0, 112, 255], [51, 0, 255], [0, 194, 255], [0, 122, 255],
[0, 255, 163], [255, 153, 0], [0, 255, 10], [255, 112, 0],
[143, 255, 0], [82, 0, 255], [163, 255, 0], [255, 235, 0],
[8, 184, 170], [133, 0, 255], [0, 255, 92], [184, 0, 255],
[255, 0, 31], [0, 184, 255], [0, 214, 255], [255, 0, 112],
[92, 255, 0], [0, 224, 255], [112, 224, 255], [70, 184, 160],
[163, 0, 255], [153, 0, 255], [71, 255, 0], [255, 0, 163],
[255, 204, 0], [255, 0, 143], [0, 255, 235], [133, 255, 0],
[255, 0, 235], [245, 0, 255], [255, 0, 122], [255, 245, 0],
[10, 190, 212], [214, 255, 0], [0, 204, 255], [20, 0, 255],
[255, 255, 0], [0, 153, 255], [0, 41, 255], [0, 255, 204],
[41, 0, 255], [41, 255, 0], [173, 0, 255], [0, 245, 255],
[71, 0, 255], [122, 0, 255], [0, 255, 184], [0, 92, 255],
[184, 255, 0], [0, 133, 255], [255, 214, 0], [25, 194, 194],
[102, 255, 0], [92, 0, 255], [107, 255, 200], [58, 41, 149],
[183, 121, 142], [255, 73, 97], [107, 142, 35],
[190, 153, 153], [146, 139, 141], [70, 130, 180],
[134, 199, 156], [209, 226, 140], [96, 36, 108], [96, 96, 96],
[64, 170, 64], [152, 251, 152], [208, 229, 228],
[206, 186, 171], [152, 161, 64], [116, 112, 0], [0, 114, 143],
[102, 102, 156], [250, 141, 255]])
palette=[(120, 120, 120), (180, 120, 120), (6, 230, 230), (80, 50, 50),
(4, 200, 3), (120, 120, 80), (140, 140, 140), (204, 5, 255),
(230, 230, 230), (4, 250, 7), (224, 5, 255), (235, 255, 7),
(150, 5, 61), (120, 120, 70), (8, 255, 51), (255, 6, 82),
(143, 255, 140), (204, 255, 4), (255, 51, 7), (204, 70, 3),
(0, 102, 200), (61, 230, 250), (255, 6, 51), (11, 102, 255),
(255, 7, 71), (255, 9, 224), (9, 7, 230), (220, 220, 220),
(255, 9, 92), (112, 9, 255), (8, 255, 214), (7, 255, 224),
(255, 184, 6), (10, 255, 71), (255, 41, 10), (7, 255, 255),
(224, 255, 8), (102, 8, 255), (255, 61, 6), (255, 194, 7),
(255, 122, 8), (0, 255, 20), (255, 8, 41), (255, 5, 153),
(6, 51, 255), (235, 12, 255), (160, 150, 20), (0, 163, 255),
(140, 140, 140), (250, 10, 15), (20, 255, 0), (31, 255, 0),
(255, 31, 0), (255, 224, 0), (153, 255, 0), (0, 0, 255),
(255, 71, 0), (0, 235, 255), (0, 173, 255), (31, 0, 255),
(11, 200, 200), (255, 82, 0), (0, 255, 245), (0, 61, 255),
(0, 255, 112), (0, 255, 133), (255, 0, 0), (255, 163, 0),
(255, 102, 0), (194, 255, 0), (0, 143, 255), (51, 255, 0),
(0, 82, 255), (0, 255, 41), (0, 255, 173), (10, 0, 255),
(173, 255, 0), (0, 255, 153), (255, 92, 0), (255, 0, 255),
(255, 0, 245), (255, 0, 102), (255, 173, 0), (255, 0, 20),
(255, 184, 184), (0, 31, 255), (0, 255, 61), (0, 71, 255),
(255, 0, 204), (0, 255, 194), (0, 255, 82), (0, 10, 255),
(0, 112, 255), (51, 0, 255), (0, 194, 255), (0, 122, 255),
(0, 255, 163), (255, 153, 0), (0, 255, 10), (255, 112, 0),
(143, 255, 0), (82, 0, 255), (163, 255, 0), (255, 235, 0),
(8, 184, 170), (133, 0, 255), (0, 255, 92), (184, 0, 255),
(255, 0, 31), (0, 184, 255), (0, 214, 255), (255, 0, 112),
(92, 255, 0), (0, 224, 255), (112, 224, 255), (70, 184, 160),
(163, 0, 255), (153, 0, 255), (71, 255, 0), (255, 0, 163),
(255, 204, 0), (255, 0, 143), (0, 255, 235), (133, 255, 0),
(255, 0, 235), (245, 0, 255), (255, 0, 122), (255, 245, 0),
(10, 190, 212), (214, 255, 0), (0, 204, 255), (20, 0, 255),
(255, 255, 0), (0, 153, 255), (0, 41, 255), (0, 255, 204),
(41, 0, 255), (41, 255, 0), (173, 0, 255), (0, 245, 255),
(71, 0, 255), (122, 0, 255), (0, 255, 184), (0, 92, 255),
(184, 255, 0), (0, 133, 255), (255, 214, 0), (25, 194, 194),
(102, 255, 0), (92, 0, 255), (107, 255, 200), (58, 41, 149),
(183, 121, 142), (255, 73, 97), (107, 142, 35),
(190, 153, 153), (146, 139, 141), (70, 130, 180),
(134, 199, 156), (209, 226, 140), (96, 36, 108), (96, 96, 96),
(64, 170, 64), (152, 251, 152), (208, 229, 228),
(206, 186, 171), (152, 161, 64), (116, 112, 0), (0, 114, 143),
(102, 102, 156), (250, 141, 255)])
2 changes: 1 addition & 1 deletion mmdet/datasets/transforms/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def transform(self, results: dict) -> dict:
img_meta = {}
for key in self.meta_keys:
assert key in results, f'`{key}` is not found in `results`, ' \
f'the valid keys are {list(results)}.'
f'the valid keys are {list(results)}.'
img_meta[key] = results[key]

data_sample.set_metainfo(img_meta)
Expand Down
6 changes: 3 additions & 3 deletions mmdet/datasets/transforms/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def transform(self, results: dict) -> dict:

def __repr__(self):
return self.__class__.__name__ + \
f'(num_max_proposals={self.num_max_proposals})'
f'(num_max_proposals={self.num_max_proposals})'


@TRANSFORMS.register_module()
Expand Down Expand Up @@ -796,8 +796,8 @@ def transform(self, results: dict) -> Union[dict, None]:

def __repr__(self):
return self.__class__.__name__ + \
f'(min_gt_bbox_wh={self.min_gt_bbox_wh}, ' \
f'keep_empty={self.keep_empty})'
f'(min_gt_bbox_wh={self.min_gt_bbox_wh}, ' \
f'keep_empty={self.keep_empty})'


@TRANSFORMS.register_module()
Expand Down
32 changes: 16 additions & 16 deletions mmdet/datasets/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2458,40 +2458,40 @@ def _mosaic_combine(
if loc == 'top_left':
# index0 to top left part of image
x1, y1, x2, y2 = max(center_position_xy[0] - img_shape_wh[0], 0), \
max(center_position_xy[1] - img_shape_wh[1], 0), \
center_position_xy[0], \
center_position_xy[1]
max(center_position_xy[1] - img_shape_wh[1], 0), \
center_position_xy[0], \
center_position_xy[1]
crop_coord = img_shape_wh[0] - (x2 - x1), img_shape_wh[1] - (
y2 - y1), img_shape_wh[0], img_shape_wh[1]

elif loc == 'top_right':
# index1 to top right part of image
x1, y1, x2, y2 = center_position_xy[0], \
max(center_position_xy[1] - img_shape_wh[1], 0), \
min(center_position_xy[0] + img_shape_wh[0],
self.img_scale[0] * 2), \
center_position_xy[1]
max(center_position_xy[1] - img_shape_wh[1], 0), \
min(center_position_xy[0] + img_shape_wh[0],
self.img_scale[0] * 2), \
center_position_xy[1]
crop_coord = 0, img_shape_wh[1] - (y2 - y1), min(
img_shape_wh[0], x2 - x1), img_shape_wh[1]

elif loc == 'bottom_left':
# index2 to bottom left part of image
x1, y1, x2, y2 = max(center_position_xy[0] - img_shape_wh[0], 0), \
center_position_xy[1], \
center_position_xy[0], \
min(self.img_scale[1] * 2, center_position_xy[1] +
img_shape_wh[1])
center_position_xy[1], \
center_position_xy[0], \
min(self.img_scale[1] * 2, center_position_xy[1] +
img_shape_wh[1])
crop_coord = img_shape_wh[0] - (x2 - x1), 0, img_shape_wh[0], min(
y2 - y1, img_shape_wh[1])

else:
# index3 to bottom right part of image
x1, y1, x2, y2 = center_position_xy[0], \
center_position_xy[1], \
min(center_position_xy[0] + img_shape_wh[0],
self.img_scale[0] * 2), \
min(self.img_scale[1] * 2, center_position_xy[1] +
img_shape_wh[1])
center_position_xy[1], \
min(center_position_xy[0] + img_shape_wh[0],
self.img_scale[0] * 2), \
min(self.img_scale[1] * 2, center_position_xy[1] +
img_shape_wh[1])
crop_coord = 0, 0, min(img_shape_wh[0],
x2 - x1), min(y2 - y1, img_shape_wh[1])

Expand Down
6 changes: 3 additions & 3 deletions projects/XDecoder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Since semantic segmentation is a pixel-level task, we don't need to use a thresh
```

| Model | mIoU | mIOU(official) | Config |
| :---------------------------------- |:-----:| :------------: | :--------------------------------------------------------------------: |
| :---------------------------------- | :---: | :------------: | :--------------------------------------------------------------------: |
| `xdecoder_focalt_best_openseg.pt`\* | 19.06 | 18.97 | [config](configs/xdecoder-tiny_zeroshot_open-vocab-panoptic_ade20k.py) |

### Semantic segmentation on COCO2017
Expand Down Expand Up @@ -175,8 +175,8 @@ Prepare your dataset according to the [docs](https://mmdetection.readthedocs.io/
```

| Model | Mask mAP | Mask mAP(official) | Config |
| :-------------------------------------------------- | :------: |-------------------:| :------------------------------------------------------------------: |
| `xdecoder-tiny_zeroshot_open-vocab-instance_coco`\* | 39.8 | 39.7 | [config](configs/xdecoder-tiny_zeroshot_open-vocab-instance_coco.py) |
| :-------------------------------------------------- | :------: | -----------------: | :------------------------------------------------------------------: |
| `xdecoder-tiny_zeroshot_open-vocab-instance_coco`\* | 39.8 | 39.7 | [config](configs/xdecoder-tiny_zeroshot_open-vocab-instance_coco.py) |

### Panoptic segmentation on COCO2017

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
backend_args=_base_.backend_args),
dict(
type='ResizeShortestEdge', scale=640, max_size=2560, backend='pillow'),
dict(
type='LoadAnnotations',
with_bbox=False,
with_mask=False,
with_seg=True,
reduce_zero_label=True),
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
dict(
type='PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
backend_args=_base_.backend_args),
dict(
type='ResizeShortestEdge', scale=800, max_size=1333, backend='pillow'),
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
dict(
type='PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
Expand Down
Loading

0 comments on commit f741c35

Please sign in to comment.