You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

RAI 1.5 ESRGAN Inference (C++)

A C++ command-line tool for running ESRGAN (Enhanced Super-Resolution Generative Adversarial Networks) inference using ONNX Runtime with support for both CPU and AMD NPU (Neural Processing Unit) execution via VitisAI Execution Provider.

Overview

This tool performs image super-resolution using pre-trained ESRGAN models, taking low-resolution images as input and producing high-resolution upscaled outputs. It supports execution on both CPU and AMD Ryzen AI NPUs for accelerated inference.

The tool has two versions (RAI 1.4) and 1.5 (RAI 1.5)

The two versions differ in CMakeLists.txt, config files, and vai_ep options that are passed. These instructions are for the RAI 1.5.

Required Files

  • ONNX Model: ESRGAN model file (esrgan_fp32_qdq.onnx)
  • Config JSON: VitisAI configuration file (vaip_config.json)
  • esrgan_cache: Precompiled cache to speed up model loading (esrgan_cahce)
  • Runtime DLLs: Ryzen AI runtime libraries (automatically copied from Ryzen AI SDK during build)
  • XCLBIN Files: NPU binary files (automatically copied from Ryzen AI SDK during build)
  • OpenCV Dependencies: OpenCV DLLs (included in opencv/build/x64/vc16/bin/)

Building the Project

The build process automatically copies all required dependencies to the output directory, making the executable completely self-contained for distribution.

Prerequisites for Building

It is recommend to use the Developer Command Prompt for Visual Studio 2022.

The path to RYZEN_AI_INSTALLATION_PATH needs to be set properly for the code to run properly. This can be done in one of two ways:

  1. activating the conda environment for Ryzen AI 1.5
conda activate ryzenai-1.5
  1. setting the environment variable manually in the command prompt:
set RYZEN_AI_INSTALLATION_PATH=C:\Program Files\RyzenAI\1.5.0

The build script can be built using the compile.bat file, or manually using CMake.

Option 1: Using the Build Script (Recommended)

    1. Run the build script:
    compile.bat
    

Option 2: Manual Build with CMAKE

  1. Generate build files with CMake:

    cmake -DCMAKE_CONFIGURATION_TYPES=Release -A x64 -T host=x64 -B build -S . -G "Visual Studio 17 2022"
    
  2. Build the project:

    cmake --build .\build --config Release
    

Source Files

src/
β”œβ”€β”€ main.cpp           # Main application logic
β”œβ”€β”€ npu_util.cpp       # NPU utility functions  
β”œβ”€β”€ npu_util.h         # NPU utility headers
└── cxxopts.hpp        # Command-line argument parsing (header-only library)

Project Root

./
β”œβ”€β”€ bird_input.png             # Sample input image
β”œβ”€β”€ CMakeLists.txt             # Build configuration
β”œβ”€β”€ compile.bat                # Build script for Windows
β”œβ”€β”€ vaip_config.json         # VitisAI EP configuration
β”œβ”€β”€ esrgan_fp32_qdq.onnx      # ONNX model file
β”œβ”€β”€ esrgan_cache/              # VitisAI compilation cache (generated after first run)
β”œβ”€β”€ opencv/                    # Local OpenCV installation
β”‚   └── build/                 # Pre-built OpenCV binaries and headers
└── src/                       # Source code directory

Usage

Command-Line Syntax

esrgan_inference.exe [OPTIONS]

Required Arguments

  • -m, --model <file> : ONNX model filename (relative to executable directory)
  • -c, --config <file> : JSON configuration filename (relative to executable directory)

Optional Arguments

  • -i, --input_image <file> : Input image file (default: ..\..\bird_input.png)
  • -o, --output_image <file> : Output image file (default: output_image.png)
  • -k, --cache_key <string> : Cache key for VitisAI EP (default: empty)
  • -d, --cache_dir <string> : Cache directory for VitisAI EP (default: empty)
  • -x, --xclbin <file> : XCLBIN filename for NPU (default: auto-selected)
  • -h, --help : Show help message

Example Usage

esrgan_inference.exe ^
    -m esrgan_fp32_qdq.onnx ^
    -c vaip_config.json ^
    -d . ^
    -k esrgan_cache
    -i ..\..\bird_input.png ^
    -o output_image.png ^

This example demonstrates:

  • Using model and config files from the build directory (automatically copied)
  • Relative paths for input images (from project root)
  • Using the existing supplied VitisAI cache directory for faster subsequent runs

Note: The esrgan_cache/ directory is created automatically during the first NPU inference run if the enable_cache_file_io_in_mem is set to 0 in the vai_ep_options If this option isn't set, the cache will be stored in memory only and the model will be recompiled every time the application is run, which can be slow.

The esrgan_cache directory contains compiled model artifacts that significantly speed up subsequent runs. You can point to this existing cache using the -d and -k parameters.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including amd/RyzenAI-1.5-ESRGAN-Inference-ryzen-strix-cpp