Skip to content

Commit 8559829

Browse files
committed
linting
1 parent 47fb880 commit 8559829

3 files changed

Lines changed: 175 additions & 33 deletions

File tree

tests/unit/test_scene_mask_annotation_3d_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import pytest
1515
from PIL import Image
1616

17-
from vizion3d.annotation.commands import SceneMaskAnnotation3DCommand
1817
from vizion3d.annotation._geometry import _extract_cloud_arrays, _render_front_view
18+
from vizion3d.annotation.commands import SceneMaskAnnotation3DCommand
1919
from vizion3d.annotation.models import SceneMaskAnnotation3DConfig
2020
from vizion3d.annotation.scene_handlers import SceneMaskAnnotation3DHandler
2121
from vizion3d.annotation.segformer import ADE20K_CLASSES, ADE20K_PALETTE

tests/unit/test_segformer_backend.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,15 @@ def test_class_list_has_150_entries(self):
6262

6363
def test_coco_aligned_names_applied(self):
6464
# the 7 unambiguous renames use the COCO name, not the ADE name
65-
for coco_name in ["couch", "dining table", "potted plant", "laptop", "tv",
66-
"motorcycle", "wine glass"]:
65+
for coco_name in [
66+
"couch",
67+
"dining table",
68+
"potted plant",
69+
"laptop",
70+
"tv",
71+
"motorcycle",
72+
"wine glass",
73+
]:
6774
assert coco_name in S.ADE20K_CLASSES
6875
for ade_name in ["sofa", "television receiver", "minibike", "computer"]:
6976
assert ade_name not in S.ADE20K_CLASSES

vizion3d/annotation/segformer.py

Lines changed: 165 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,156 @@
4646
# exists so masks flow straight into COCO-keyed pipelines (e.g. ScaleObservation
4747
# size priors). Ambiguous many-to-one cases (animal, pot) keep the ADE name.
4848
ADE20K_CLASSES = [
49-
"wall", "building", "sky", "floor", "tree", "ceiling", "road", "bed",
50-
"windowpane", "grass", "cabinet", "sidewalk", "person", "earth", "door",
51-
"dining table", "mountain", "potted plant", "curtain", "chair", "car",
52-
"water", "painting", "couch", "shelf", "house", "sea", "mirror", "rug",
53-
"field", "armchair", "seat", "fence", "desk", "rock", "wardrobe", "lamp",
54-
"bathtub", "railing", "cushion", "base", "box", "column", "signboard",
55-
"chest of drawers", "counter", "sand", "sink", "skyscraper", "fireplace",
56-
"refrigerator", "grandstand", "path", "stairs", "runway", "case",
57-
"pool table", "pillow", "screen door", "stairway", "river", "bridge",
58-
"bookcase", "blind", "coffee table", "toilet", "flower", "book", "hill",
59-
"bench", "countertop", "stove", "palm", "kitchen island", "laptop",
60-
"swivel chair", "boat", "bar", "arcade machine", "hovel", "bus", "towel",
61-
"light", "truck", "tower", "chandelier", "awning", "streetlight", "booth",
62-
"tv", "airplane", "dirt track", "apparel", "pole", "land", "bannister",
63-
"escalator", "ottoman", "bottle", "buffet", "poster", "stage", "van",
64-
"ship", "fountain", "conveyer belt", "canopy", "washer", "plaything",
65-
"swimming pool", "stool", "barrel", "basket", "waterfall", "tent", "bag",
66-
"motorcycle", "cradle", "oven", "ball", "food", "step", "tank",
67-
"trade name", "microwave", "pot", "animal", "bicycle", "lake", "dishwasher",
68-
"screen", "blanket", "sculpture", "hood", "sconce", "vase", "traffic light",
69-
"tray", "ashcan", "fan", "pier", "crt screen", "plate", "monitor",
70-
"bulletin board", "shower", "radiator", "wine glass", "clock", "flag",
49+
"wall",
50+
"building",
51+
"sky",
52+
"floor",
53+
"tree",
54+
"ceiling",
55+
"road",
56+
"bed",
57+
"windowpane",
58+
"grass",
59+
"cabinet",
60+
"sidewalk",
61+
"person",
62+
"earth",
63+
"door",
64+
"dining table",
65+
"mountain",
66+
"potted plant",
67+
"curtain",
68+
"chair",
69+
"car",
70+
"water",
71+
"painting",
72+
"couch",
73+
"shelf",
74+
"house",
75+
"sea",
76+
"mirror",
77+
"rug",
78+
"field",
79+
"armchair",
80+
"seat",
81+
"fence",
82+
"desk",
83+
"rock",
84+
"wardrobe",
85+
"lamp",
86+
"bathtub",
87+
"railing",
88+
"cushion",
89+
"base",
90+
"box",
91+
"column",
92+
"signboard",
93+
"chest of drawers",
94+
"counter",
95+
"sand",
96+
"sink",
97+
"skyscraper",
98+
"fireplace",
99+
"refrigerator",
100+
"grandstand",
101+
"path",
102+
"stairs",
103+
"runway",
104+
"case",
105+
"pool table",
106+
"pillow",
107+
"screen door",
108+
"stairway",
109+
"river",
110+
"bridge",
111+
"bookcase",
112+
"blind",
113+
"coffee table",
114+
"toilet",
115+
"flower",
116+
"book",
117+
"hill",
118+
"bench",
119+
"countertop",
120+
"stove",
121+
"palm",
122+
"kitchen island",
123+
"laptop",
124+
"swivel chair",
125+
"boat",
126+
"bar",
127+
"arcade machine",
128+
"hovel",
129+
"bus",
130+
"towel",
131+
"light",
132+
"truck",
133+
"tower",
134+
"chandelier",
135+
"awning",
136+
"streetlight",
137+
"booth",
138+
"tv",
139+
"airplane",
140+
"dirt track",
141+
"apparel",
142+
"pole",
143+
"land",
144+
"bannister",
145+
"escalator",
146+
"ottoman",
147+
"bottle",
148+
"buffet",
149+
"poster",
150+
"stage",
151+
"van",
152+
"ship",
153+
"fountain",
154+
"conveyer belt",
155+
"canopy",
156+
"washer",
157+
"plaything",
158+
"swimming pool",
159+
"stool",
160+
"barrel",
161+
"basket",
162+
"waterfall",
163+
"tent",
164+
"bag",
165+
"motorcycle",
166+
"cradle",
167+
"oven",
168+
"ball",
169+
"food",
170+
"step",
171+
"tank",
172+
"trade name",
173+
"microwave",
174+
"pot",
175+
"animal",
176+
"bicycle",
177+
"lake",
178+
"dishwasher",
179+
"screen",
180+
"blanket",
181+
"sculpture",
182+
"hood",
183+
"sconce",
184+
"vase",
185+
"traffic light",
186+
"tray",
187+
"ashcan",
188+
"fan",
189+
"pier",
190+
"crt screen",
191+
"plate",
192+
"monitor",
193+
"bulletin board",
194+
"shower",
195+
"radiator",
196+
"wine glass",
197+
"clock",
198+
"flag",
71199
]
72200

73201

@@ -99,8 +227,9 @@ def _build_palette(num_colors: int) -> np.ndarray:
99227
class OverlapPatchEmbeddings(nn.Module):
100228
def __init__(self, patch_size, stride, in_ch, out_ch):
101229
super().__init__()
102-
self.proj = nn.Conv2d(in_ch, out_ch, kernel_size=patch_size, stride=stride,
103-
padding=patch_size // 2)
230+
self.proj = nn.Conv2d(
231+
in_ch, out_ch, kernel_size=patch_size, stride=stride, padding=patch_size // 2
232+
)
104233
self.layer_norm = nn.LayerNorm(out_ch, eps=LN_EPS)
105234

106235
def forward(self, x):
@@ -212,11 +341,16 @@ def __init__(self):
212341
in_ch = 3
213342
for i in range(4):
214343
self.patch_embeddings.append(
215-
OverlapPatchEmbeddings(PATCH_SIZES[i], STRIDES[i], in_ch, HIDDEN_SIZES[i]))
216-
self.block.append(nn.ModuleList([
217-
SegformerLayer(HIDDEN_SIZES[i], NUM_HEADS[i], SR_RATIOS[i], MLP_RATIOS[i])
218-
for _ in range(DEPTHS[i])
219-
]))
344+
OverlapPatchEmbeddings(PATCH_SIZES[i], STRIDES[i], in_ch, HIDDEN_SIZES[i])
345+
)
346+
self.block.append(
347+
nn.ModuleList(
348+
[
349+
SegformerLayer(HIDDEN_SIZES[i], NUM_HEADS[i], SR_RATIOS[i], MLP_RATIOS[i])
350+
for _ in range(DEPTHS[i])
351+
]
352+
)
353+
)
220354
self.layer_norm.append(nn.LayerNorm(HIDDEN_SIZES[i], eps=LN_EPS))
221355
in_ch = HIDDEN_SIZES[i]
222356

@@ -300,7 +434,8 @@ def _preprocess(image: Image.Image, inference_size: int):
300434
if inference_size and inference_size > 0:
301435
scale = inference_size / min(orig_w, orig_h)
302436
resized = image.resize(
303-
(max(1, round(orig_w * scale)), max(1, round(orig_h * scale))), Image.BILINEAR)
437+
(max(1, round(orig_w * scale)), max(1, round(orig_h * scale))), Image.BILINEAR
438+
)
304439
else:
305440
resized = image
306441
arr = np.asarray(resized, dtype=np.float32) / 255.0

0 commit comments

Comments
 (0)