Skip to content

Commit 6e6fca6

Browse files
author
Julia Kamelina
authored
Update pspnet config (#3144)
* update pspnet cofig * update readme * update crop_padding * rename postprocessing
1 parent 915f070 commit 6e6fca6

File tree

5 files changed

+40
-12
lines changed

5 files changed

+40
-12
lines changed

models/public/pspnet-pytorch/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
| Metric | Value |
1919
| --------- | ----- |
20-
| mean_iou | 70.6% |
20+
| mean_iou | 70.1% |
2121

2222
Accuracy metrics were obtained with fixed input resolution 512x512.
2323

models/public/pspnet-pytorch/accuracy-check.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,20 @@ models:
77
- name: VOC2012_Segmentation
88
preprocessing:
99
- type: resize
10-
aspect_ratio_scale: frcnn_keep_aspect_ratio
11-
dst_height: 512
12-
dst_width: 2048
13-
- type: crop
10+
aspect_ratio_scale: fit_to_window
1411
size: 512
12+
- type: padding
13+
size: 512
14+
pad_type: right_bottom
15+
pad_value: '123.675, 116.28, 103.53'
1516
postprocessing:
17+
- type: crop_padded_prediction
1618
- type: resize_segmentation_mask
17-
apply_to: annotation
18-
to_dst_image_size: True
19+
apply_to: prediction
1920
- type: encode_segmentation_mask
2021
apply_to: annotation
21-
- type: crop_segmentation_mask
22-
size: 512
23-
apply_to: annotation
2422
metrics:
2523
- type: mean_iou
2624
use_argmax: false
2725
presenter: print_scalar
28-
reference: 0.706
26+
reference: 0.701

tools/accuracy_checker/openvino/tools/accuracy_checker/postprocessor/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Accuracy Checker supports following set of postprocessors:
6464
You can also use `size` instead in case when destination sizes are equal for all three dimensions.
6565
* `crop_or_pad-segmentation_mask` - performs central cropping if original mask size greater then destination size and padding in case, when source size lower than destination. Padding filling value is 0, realization - right-bottom.
6666
* `dst_width` and `dst_height` are destination width and height for keypoints resizing respectively. You can also use `size` instead in case when destination sizes are equal. Supported representations: `SegmentationAnotation`, `SegmentationPrediction`.
67+
* `crop_padded_prediction` - performs cropping if original image was padded, to the padding size. Supported representations: `SegmentationAnotation`, `SegmentationPrediction`.
6768
* `heatmap2keypoints` - extract landmark keypoints from the heatmap. Supported representations: `FacialLandmarksHeatMapAnnotation`, `FacialLandmarksHeatMapPrediction`.
6869
* `clip_segmentation_mask` - clipping segmentation mask values. Supported representations: `BrainTumorSegmentationAnnotation`, `BrainTumorSegmentationPrediction`.
6970
* `min_value` - lower bound of range.

tools/accuracy_checker/openvino/tools/accuracy_checker/postprocessor/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from .clip_points import ClipPoints
4141
from .extend_segmentation_mask import ExtendSegmentationMask
4242
from .zoom_segmentation_mask import ZoomSegMask
43-
from .crop_segmentation_mask import CropSegmentationMask, CropOrPadSegmentationMask
43+
from .crop_segmentation_mask import CropSegmentationMask, CropOrPadSegmentationMask, CropPaddingSegmentationMask
4444
from .clip_segmentation_mask import ClipSegmentationMask
4545
from .normalize_boxes import NormalizeBoxes
4646
from .brats_postprocessing import SegmentationPredictionResample, TransformBratsPrediction
@@ -99,6 +99,7 @@
9999
'ZoomSegMask',
100100
'CropSegmentationMask',
101101
'CropOrPadSegmentationMask',
102+
'CropPaddingSegmentationMask',
102103
'ClipSegmentationMask',
103104
'ArgMaxSegmentationMask',
104105

tools/accuracy_checker/openvino/tools/accuracy_checker/postprocessor/crop_segmentation_mask.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,31 @@ def process_mask(self, mask):
145145
cropped, offset_pad_height, offset_pad_width, self.dst_height, self.dst_width
146146
)
147147
return resized
148+
149+
150+
class CropPaddingSegmentationMask(Postprocessor):
151+
__provider__ = 'crop_padded_prediction'
152+
153+
annotation_types = (SegmentationAnnotation, )
154+
prediction_types = (SegmentationPrediction, )
155+
156+
def process_image(self, annotation, prediction):
157+
raise RuntimeError("Since `process_image_with_metadata` is overridden, this method MUST NOT be called")
158+
159+
def process_image_with_metadata(self, annotation, prediction, image_metadata=None):
160+
assert image_metadata and 'padding' in image_metadata, (
161+
"Postprocessing step `crop_padded_prediction` cannot work without metadata with `padding` field")
162+
163+
top, left, bottom, right = image_metadata.get('padding', (0, 0, 0, 0))
164+
for pred in prediction:
165+
mask = pred.mask
166+
if mask.ndim == 2:
167+
h, w = mask.shape
168+
mask = mask[top:(h - bottom), left:(w - right)]
169+
pred.mask = mask
170+
continue
171+
_, h, w = mask.shape
172+
mask = mask[:, top:(h - bottom), left:(w - right)]
173+
pred.mask = mask
174+
175+
return annotation, prediction

0 commit comments

Comments
 (0)