HRNet for background segmentation
The model operating at 512x512 resolution for semantic background segmentation on images.
It was introduced in the paper Object-Contextual Representations for Semantic Segmentation by Yuhui Yuan et al.
We have developed a modified version optimized for AMD Ryzen AI.
Model description
HRNet is an advanced deep learning architecture designed for image segmentation tasks. It maintains high-resolution representations throughout the network, enabling precise semantic segmentation with accurate spatial details.
Intended uses & limitations
You can use this model for background segmentation tasks. See the model hub for all available hrnet-bg-seg models.
How to use
Installation
# inference only
pip install -r requirements-infer.txt
# inference & evaluation
pip install -r requirements-eval.txt
Data Preparation (optional: for evaluation)
Run python download_dut_omron.py to automatically download and extract the DUT-OMRON dataset into the datasets directory.
Alternatively, you can manually download DUT-OMRON Dataset Images and Pixel-wise Ground Truth from the DUT-OMRON page, then extract both archives into datasets.
Your datasets folder should look like this:
datasets
βββ DUT-OMRON-image
β βββ im005.jpg
β βββ ...
βββ pixelwiseGT-new-PNG
βββ im005.png
βββ ...
Test & Evaluation
- Run inference on images
python onnx_inference.py --onnx seg_hrnet_nchw_u8s8.onnx --input /Path/To/Your/Image --out-dir outputs
Arguments:
--input: Accepts either a single image file path or a directory path. If it's a file, the script will process that image only. If it's a directory, the script will recursively scan for .png, .jpg, and .jpeg files and process all of them.
--out-dir: Output directory where the restored images will be saved.
- Evaluate the quantized model
python onnx_eval.py \
--onnx seg_hrnet_nchw_u8s8.onnx \
--img-dir datasets/DUT-OMRON-image \
--gt-mask-dir datasets/pixelwiseGT-new-PNG \
--out-dir outputs/
Performance
| Model | MAE(β¬) | s-measure(β¬) | max f-measure(β¬) | weighted f-measure(β¬) |
|---|---|---|---|---|
| HRNet (fp32) | 0.0803 | 0.7586 | 0.6867 | 0.6570 |
| HRNet (u8s8) | 0.0789 | 0.7611 | 0.6892 | 0.6600 |
Note:
- Metrics are calculated on the
DUT-OMRONdataset. - Evaluation uses PySODMetrics v1.6.0 as the evaluation tool.
@article{YuanCW19,
title={Object-Contextual Representations for Semantic Segmentation},
author={Yuhui Yuan and Xilin Chen and Jingdong Wang},
booktitle={ECCV},
year={2020}
}