File size: 2,832 Bytes
c2ba1ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
license: apache-2.0
datasets:
- Chris1/cityscapes
language:
- en
metrics:
- mean_iou
pipeline_tag: image-segmentation
tags:
- Image Segmentation
- Semantic Segmentation
- Computer Vision
- Cityscapes
- HRNet
- ONNX
- Int8 quantization
- RyzenAI
---

# HRNet model trained on Cityscapes

HRNet trained on Cityscapes dataset at resolution 512x1024 for semantic segmentation on images. 
It was introduced in the paper [Segmentation Transformer: Object-Contextual Representations for Semantic Segmentation](https://arxiv.org/pdf/1909.11065.pdf) by Yuhui Yuan et al. 
The code version we use from [this repository](https://github.com/HRNet/HRNet-Semantic-Segmentation).

We develop a modified version that could be supported by [AMD Ryzen AI](https://ryzenai.docs.amd.com/en/latest/inst.html).


## Model description

HRNet is an advanced algorithm used for image segmentation. It is based on deep learning techniques and is capable of providing accurate semantic segmentation in images.


## Intended uses & limitations

You can use the raw model for semantic segmentation. See the [model hub](https://huggingface.co./models?sort=trending&search=amd%2Fhrnet) to look for all available HRNet models.


## How to use

### Installation

   Follow [Ryzen AI Installation](https://ryzenai.docs.amd.com/en/latest/inst.html) to prepare the environment for Ryzen AI.
   Run the following script to install pre-requisites for this model.
   ```bash
   pip install -r requirements.txt 
   ```


### Data Preparation (optional: for accuracy evaluation)
1. Download the [Cityscapes](https://www.cityscapes-dataset.com/) dataset, which includes images and annotations. Download gtFine_trainvaltest.zip (241MB) and leftImg8bit_trainvaltest.zip (11GB).
2. Organise the dataset directory as follows:
```Shell
  ./data/cityscapes/
    gtFine
    leftImg8bit
    train.lst
    val.lst
    test.lst
```

### Test & Evaluation
 - Run inference on a single image
  ```python
  python hrnet_quantized_onnx_inference.py -m HighResolutionNet_int.onnx -idir PATH_TO_IMAGES(like .\data\cityscapes\leftImg8bit\val\frankfurt) --ipu --provider_config Path\To\vaip_config.json
  #return segmentaion logits and can visualize the result.
  ```
*Note: __vaip_config.json__ is located at the setup package of Ryzen AI (refer to [Installation](#installation))*

 - Test accuracy of the quantized model on Cityscapes.
  ```Shell
  python hrnet_quantized_onnx_eval.py -m .\HighResolutionNet_int.onnx -r .\data\cityscapes -l .\val.lst --ipu --provider_config .\vaip_config.json
  ```

### Performance
| Model | miou|
|:-|:-:|
| HRNet_int8_onnx_model (512x1024) | 72.31% |


```bibtex
@article{YuanCW19,
  title={Object-Contextual Representations for Semantic Segmentation},
  author={Yuhui Yuan and Xilin Chen and Jingdong Wang},
  booktitle={ECCV},
  year={2020}
}
```