Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stdc benchmark & fix mask2former predict bug #286

Merged
merged 12 commits into from
Feb 17, 2023
1 change: 1 addition & 0 deletions docs/source/model_zoo_seg.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ trained on **Cityscapes**.
| Algorithm | Config | Params<br/>(backbone/total) | Train memory<br/>(GB) | inference time(V100)<br/>(ms/img) | mIoU | Download |
| ---------- | ------------------------------------------------------------ | ------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| STDC1 | [stdc1_cityscape_8xb6_e1290](https://github.com/alibaba/EasyCV/tree/master/configs/segmentation/stdc/stdc1_cityscape_8xb6_e1290.py) | 7.7M/8.5M | 4.5 | 11.9ms | 75.4 | [model](http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/modelzoo/segmentation/stdc/stdc1_cityscapes/epoch_1250.pth) - [log](http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/modelzoo/segmentation/stdc/stdc1_cityscapes/20230214_173123.log.json) |
| STDC2 | [stdc2_cityscape_8xb6_e1290](https://github.com/alibaba/EasyCV/tree/master/configs/segmentation/stdc/stdc2_cityscape_8xb6_e1290.py) | 11.6M/12.6M | 5.6 | 15.4ms | 76.6 | [model](http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/modelzoo/segmentation/stdc/stdc2_cityscapes/epoch_1280.pth) - [log](http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/modelzoo/segmentation/stdc/stdc2_cityscapes/20230216_110522.log.json) |

## Mask2former

Expand Down
6 changes: 4 additions & 2 deletions easycv/predictors/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,11 @@ def model_forward(self, inputs):
outputs = self.model.forward(**inputs, mode='test', encode=False)
return outputs

def show_panoptic(self, img, masks, labels):
def show_panoptic(self, img, masks, labels_ids, **kwargs):
palette = np.asarray(self.cfg.PALETTE)
palette = palette[labels % 1000]
# ids have already convert to label in process_single function
# palette = palette[labels_ids % 1000]
palette = palette[labels_ids]
panoptic_result = draw_masks(img, masks, palette)
return panoptic_result

Expand Down
10 changes: 2 additions & 8 deletions tests/predictors/test_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ def test_panoptic_single(self):
predict_out[0]['labels_ids'].tolist(),
[71, 69, 39, 39, 39, 128, 127, 122, 118, 115, 111, 104, 84, 83])

pan_img = predictor.show_panoptic(
img,
masks=predict_out[0]['masks'],
labels=predict_out[0]['labels_ids'])
pan_img = predictor.show_panoptic(img, **predict_out[0])
cv2.imwrite('pan_out.jpg', pan_img)

def test_panoptic_batch(self):
Expand All @@ -168,10 +165,7 @@ def test_panoptic_batch(self):
self.assertListEqual(predict_out[i]['labels_ids'].tolist(), [
71, 69, 39, 39, 39, 128, 127, 122, 118, 115, 111, 104, 84, 83
])
pan_img = predictor.show_panoptic(
img,
masks=predict_out[i]['masks'],
labels=predict_out[i]['labels_ids'])
pan_img = predictor.show_panoptic(img, **predict_out[i])
cv2.imwrite(save_name, pan_img)

def test_instance_single(self):
Expand Down