File size: 5,327 Bytes
4c6a514 8c5a373 4c6a514 | 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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | ---
library_name: onnx
license: mit
tags:
- foundation
- amd
- rocm
- image-segmentation
pipeline_tag: image-segmentation
---

# HRNetv2-W48: Optimized for AMD ROCm
HRNetv2-W48 is a semantic segmentation model that assigns a class label to every pixel while maintaining high-resolution feature representations throughout the network. This repository packages inference for semantic segmentation using **ONNX Runtime**, exported and validated for **AMD ROCm** so it runs efficiently on AMD GPUs, CPUs, and NPUs.
This is based on the implementation of HRNetv2 found [here](https://github.com/HRNet/HRNet-Semantic-Segmentation).
This repository contains configurations and scripts optimized for **AMD® ROCm™** platforms. You can use the [hrnetv2 AMD scripts](https://github.com/AMD-PAVS/physical_ai_sdk/blob/main/models/hrnetv2) to reproduce results or export with custom configurations. More details on model performance can be found [here](#accuracy-pipeline).
---
## Task Overview
**Task:** Semantic segmentation
**Dataset:** Cityscapes val (500 images) · ADE20k val · LIP val (variant-specific)
**Output metrics:** mIoU (mean Intersection over Union), pixel accuracy, mean class accuracy
> **Model variants:** Default is **Cityscapes** at 1024×2048 (paper mIoU 80.9%). Override with `HRNET_VARIANT` or `HRNET_MODEL` (e.g. `export HRNET_MODEL=ade20k`) or run `make set-variant VARIANT=MODEL_LIP` for a persistent override. Run `make list-variants` for aliases.
> **NPU note:** NPU float precisions (FP32/FP16/BF16) use per-dtype `config/vitisai_config_*.json`; NPU INT8 requires `make quantize-npu-int8` before benchmark/eval.
---
## AMD ROCm Optimization
This model export has been adapted and validated for **AMD Instinct™ / Radeon™ GPUs** running **ROCm**, as well as AMD CPUs and AMD Ryzen AI NPUs. Key points:
- Validated backends: **ONNX Runtime** across CPU, GPU (MIGraphX execution provider), and NPU (VitisAI execution provider).
- No code changes required versus the upstream HRNet implementation — only environment/runtime configuration differs.
- CPU fallback path supported for environments without a ROCm-capable GPU.
| Runtime | Precision | Backend | Hardware | Notes |
|---|---|---|---|---|
| ONNX Runtime | FP32 / FP16 / BF16 / INT8 | CPU Execution Provider | AMD CPU | — |
| ONNX Runtime | FP32 / FP16 / BF16 / INT8 | MIGraphX Execution Provider | AMD Instinct™ / Radeon™ GPU (ROCm) | — |
| ONNX Runtime | FP32 / FP16 / BF16 / INT8 | VitisAI Execution Provider | AMD Ryzen AI NPU | INT8 requires Quark calibration via `make quantize-npu-int8` |
---
## Getting Started
For setup instructions, evaluation scripts, and custom configuration options, see the [hrnetv2 on GitHub](https://github.com/AMD-PAVS/physical_ai_sdk/blob/main/models/hrnetv2).
---
## Model Details
**Model Type:** Semantic segmentation, HRNetv2-W48
**Base Model:** `HRNet/HRNet-Semantic-Segmentation` (HRNetv2-W48)
**Model Stats:**
- Model variant: Cityscapes, 1024×2048 input (default) — ADE20k (520×520) and LIP (473×473) also supported
- Precision tested: FP32, FP16, BF16, INT8
---
## Accuracy Pipeline
Higher mIoU means predicted pixel labels agree more closely with ground truth — 100% is perfect overlap, 0% is no agreement.
### Metrics Explained
| Metric | Description |
|--------|-------------|
| mIoU | Primary segmentation metric — mean Intersection-over-Union averaged across all classes. Higher means better boundary alignment and class assignment across the validation set. |
| Pixel accuracy | Fraction of correctly labeled pixels — rewards overall coverage but can hide poor performance on rare classes. |
| Mean class accuracy | Average per-class accuracy — exposes imbalance when large classes dominate pixel accuracy. |
### Accuracy Results
**Full Dataset Evaluation (Cityscapes val)** — filled from `evaluation_results/`; run `make metrics` to refresh:
<!-- accuracy-table-start -->
| Device | Backend | Precision | Variant | Accuracy (%) |
|--------|---------|-----------|---------|--------------|
| CPU | ONNX Runtime | FP32 | Cityscapes | 40.54 |
| CPU | ONNX Runtime | FP16 | Cityscapes | 40.75 |
| CPU | ONNX Runtime | BF16 | Cityscapes | 40.82 |
| CPU | ONNX Runtime | INT8 | Cityscapes | 40.99 |
| GPU | ONNX Runtime | FP32 | Cityscapes | 40.86 |
| GPU | ONNX Runtime | FP16 | Cityscapes | 40.63 |
| GPU | ONNX Runtime | BF16 | Cityscapes | 40.67 |
| GPU | ONNX Runtime | INT8 | Cityscapes | 40.82 |
| NPU | ONNX Runtime | FP32 | Cityscapes | 40.49 |
| NPU | ONNX Runtime | FP16 | Cityscapes | 41.10 |
| NPU | ONNX Runtime | BF16 | Cityscapes | 40.92 |
| NPU | ONNX Runtime | INT8 | Cityscapes | 0.00 |
<!-- accuracy-table-end -->
---
## Dig Deeper
Want to explore the full evaluation scripts, config options, and other AMD-optimized model examples?
📂 **[View the full project on GitHub](https://github.com/AMD-PAVS/physical_ai_sdk/blob/main/models/hrnetv2)**
The GitHub repository includes:
- Benchmark, profile, and evaluation Makefile targets for CPU, GPU, and NPU
- Dataset staging for Cityscapes, ADE20k, and LIP variants
- ONNX export scripts and the patched upstream HRNet evaluation tooling
- Additional HRNetv2-W48 variants (Cityscapes, ADE20k, LIP)
|