An open API service indexing awesome lists of open source software.

https://github.com/amd/imagetilingnpu


https://github.com/amd/imagetilingnpu

Last synced: 7 days ago
JSON representation

Awesome Lists containing this project

README

          

# ImageTilingNPU

## Project introduction

This repository provides an implementation for deploying neural network-based image super-resolution models on the AMD XDNATM platform, leveraging the NPU(Neural Processing Unit) for efficient inference. The goal is to enable fast, low-power, and high-quality super-resolution on edge and embedded device powered by AMD XDNATM.

## Features

- High-Quality Super-Resolution: Supports neural network models for enhancing low-resolution images to high-resolution.
- AMD XDNA NPU Acceleration: Optimized for inference on AMD XDNATM Neural Processing Unit for low-latency and energy-efficient execution.
- Model Support: Both ONNX and Xmodel are supported
- Lightweight & Efficient: Minimal dependencies and optimized code for fast inference on edge devices.

## Requirements

- Windows platform with AMD XDNATM NPU hardware and NPU driver installed
- Visual Studio 2022
- Cmake > 3.4

## Build

1. Prepare onnxruntime, download onnxruntime headers and libraries from [onnxruntime OMS](https://download.amd.com/opendownload/RyzenAI/NPU_image_tiling/imagetiling_dep.zip)

2. In CMakeLists.txt, set the ORT_DIR variable to the onnxruntime path in onnxruntime OMS.

3. Copy the third_party folder in onnxruntime OMS to project root path.

4. Download opencv from https://github.com/opencv/opencv/releases/download/4.11.0/opencv-4.11.0-windows.exe, then copy the opencv2 headers and opencv_world4110.lib library to third_party folder.

5. Build the project

```
cmake -B build -S .
cmake --build build --config release
```

6. Copy build/*.exe opencv/build/x64/vc16/bin/opencv_world4110.dll onnxruntime/bin/*.dll to bin folder

## Example

Copy AMD_AIE2P_8x4x1_Overlay_CFG5.xclbin to ${XCLBIN_PATH}(any dir is okay)

### Functional test

We provided two 2 ways to implement super-resolution, both onnx and xmodel

For onnx model

```
test_SR_onnx.exe --model input.onnx --vai_options "xclbin|${XCLBIN_PATH}/AMD_AIE2P_8x4x1_Overlay_CFG5.xclbin config_file|config_file/vaip_config.json" --image input.png
```

For xmodel model

```
test_SR_xmodel.exe --model input.xmodel --vai_options "xclbin|${XCLBIN_PATH}/AMD_AIE2P_8x4x1_Overlay_CFG5.xclbin" --image input.png
```

### Performance test

Navigate to NPU driver path

```
xrt-smi configure --pmode performance
```

For onnx model

```
perf_SR_onnx.exe --model input.onnx --image_height 1440 --image_width 2560 --vai_options "xclbin|${XCLBIN_PATH}/AMD_AIE2P_8x4x1_Overlay_CFG5.xclbin ctx_idx|1"
```

For xmodel model

```
perf_SR_xmodel.exe --model input.xmodel --image_height 1440 --image_width 2560 --vai_options "xclbin|${XCLBIN_PATH}/AMD_AIE2P_8x4x1_Overlay_CFG5.xclbin ctx_idx|1"
```

## Contribute code

If you meet any problem or request a new feature, you're welcome to create an issue.
If you can solve any of the issues, you're welcome to send the PR to us.