Skip to content

Commit 0612ac3

Browse files
authored
Feat/cityscapes tutorial (#580)
* Add Citscapes dataset adapter * Add Cityscapes dataset adapter and cleanup * Update datasets/__init__.py * Correction in build_dataset arg * Add tutorial for cityscapes semanticsegmentation * Restore cityscacpescripts dependency
1 parent fd810f7 commit 0612ac3

3 files changed

Lines changed: 1217 additions & 1 deletion

File tree

examples/tutorial_cityscapes_image_segmentation.ipynb

Lines changed: 1202 additions & 0 deletions
Large diffs are not rendered by default.

perceptionmetrics/datasets/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"cityscapes_image_segmentation": CityscapesImageSegmentationDataset,
4444
"nuimages_image_segmentation": NuImagesSegmentationDataset,
4545
"nuimages_detection": NuImagesDetectionDataset,
46+
"cityscapes_image_segmentation": CityscapesImageSegmentationDataset,
4647
}
4748

4849
if CocoDataset is not None:

perceptionmetrics/models/torch_segmentation.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,20 @@ def inference(self, tensor_in: torch.Tensor) -> torch.Tensor:
349349
tensor_out = self.model(tensor_in.to(self.device))
350350

351351
if isinstance(tensor_out, dict):
352-
tensor_out = tensor_out["out"]
352+
if "out" in tensor_out:
353+
tensor_out = tensor_out["out"]
354+
elif "logits" in tensor_out:
355+
tensor_out = tensor_out["logits"]
356+
elif hasattr(tensor_out, "logits"):
357+
tensor_out = tensor_out.logits
358+
359+
if tensor_out.shape[-2:] != tensor_in.shape[-2:]:
360+
tensor_out = torch.nn.functional.interpolate(
361+
tensor_out,
362+
size=tensor_in.shape[-2:],
363+
mode="bilinear",
364+
align_corners=False,
365+
)
353366

354367
return tensor_out
355368

0 commit comments

Comments
 (0)