--- license: bsd-3-clause-clear language: - en pipeline_tag: image-to-image tags: - Real-ESRGAN - SR - Int8 --- # Real-ESRGAN This version of Real-ESRGAN has been converted to run on the Axera NPU using **w8a8** quantization. This model has been optimized with the following LoRA: Compatible with Pulsar2 version: 3.4 ## Convert tools links: For those who are interested in model conversion, you can try to export axmodel through - [The repo of original](https://github.com/xinntao/Real-ESRGAN) - [The repo of AXera Platform](https://github.com/AXERA-TECH/realesrgan.axera), which you can get the detial of guide - [Pulsar2 Link, How to Convert ONNX to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/pulsar2/introduction.html) ## Support Platform - AX650 - [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html) - [M.2 Accelerator card](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html) - AX630C - [爱芯派2](https://axera-pi-2-docs-cn.readthedocs.io/zh-cn/latest/index.html) - [Module-LLM](https://docs.m5stack.com/zh_CN/module/Module-LLM) - [LLM630 Compute Kit](https://docs.m5stack.com/zh_CN/core/LLM630%20Compute%20Kit) |Chips| 64x64 -> 256x256 | 256x256 -> 1024x1024 | |--|--|--| |AX650| 15 ms | 440 ms | |AX630C| 76 ms | 2030 ms | ## How to use Download all files from this repository to the device ``` (axcl) axera@raspberrypi:~/samples/realesrgan.axera $ tree -L 2 . ├── ax630c │   ├── realesrgan-x4-256.axmodel │   └── realesrgan-x4.axmodel ├── ax650 │   ├── realesrgan-x4-256.axmodel │   └── realesrgan-x4.axmodel ├── config.json ├── main.py ├── onnx │   ├── realesrgan-x4-256.onnx │   └── realesrgan-x4.onnx ├── output_test_256.jpg ├── out_test-256.jpg └── test_256.jpeg 3 directories, 11 file ``` ### python env requirement #### pyaxengine https://github.com/AXERA-TECH/pyaxengine ``` wget https://github.com/AXERA-TECH/pyaxengine/releases/download/0.1.3rc0/axengine-0.1.3-py3-none-any.whl pip install axengine-0.1.3-py3-none-any.whl ``` #### others ``` pip install argparse numpy opencv-python ``` ## Inference with AX630C Host, such as Module-LLM, LLM630 Compute Kit ``` root@ax630c:/mnt/qtang/realesrgan.axera# python3 main.py --input test_256.jpeg --output test_256_20e.jpeg --model ax630/realesrgan-x4-256.axmodel [INFO] Available providers: ['AxEngineExecutionProvider'] [INFO] Using provider: AxEngineExecutionProvider [INFO] Chip type: ChipType.MC20E [INFO] VNPU type: VNPUType.DISABLED [INFO] Engine version: 2.7.2a [INFO] Model type: 1 (full core) [INFO] Compiler version: 3.4 3dfd5692 input.1 [1, 256, 256, 3] uint8 1895 [1, 1024, 1024, 3] float32 Original Image Shape: (243, 243, 3) Preprocessed Image Shape: (1, 256, 256, 3) Inference Time: 2066.72 ms Output Shape: (1, 1024, 1024, 3) Final Output Image Shape: (1024, 1024, 3) root@ax630c:/mnt/qtang/realesrgan.axera# ``` ## Inference with M.2 Accelerator card [What is M.2 Accelerator card?](https://axcl-docs.readthedocs.io/zh-cn/latest/doc_guide_hardware.html), Show this DEMO based on Raspberry PI 5. ``` (axcl) axera@raspberrypi:~/samples/realesrgan.axera $ python main.py --input test_256.jpeg --output output_test_256.jpg --model realesrgan-x4-256.axmodel [INFO] Available providers: ['AXCLRTExecutionProvider'] [INFO] Using provider: AXCLRTExecutionProvider [INFO] SOC Name: AX650N [INFO] VNPU type: VNPUType.DISABLED [INFO] Compiler version: 3.4 3dfd5692 input.1 [1, 256, 256, 3] uint8 [1, 1024, 1024, 3] float32 Original Image Shape: (243, 243, 3) Preprocessed Image Shape: (1, 256, 256, 3) Inference Time: 455.81 ms Output Shape: (1, 1024, 1024, 3) Final Output Image Shape: (1024, 1024, 3) (axcl) axera@raspberrypi:~/samples/realesrgan.axera $ ``` **Input** ![](./test_256.jpeg) **Output** ![](./output_test_256.jpg)