File size: 2,901 Bytes
1266aec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2bd3be8
1266aec
 
 
 
 
 
 
 
2325de2
1266aec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9d449ad
2325de2
9d449ad
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
---
license: mit
language:
- en
pipeline_tag: image-to-image
tags:
- denosing
- ImageEnhancement
---

# ImageDenosing

This is a collection of image denosing algorithms, models have been converted to run on the Axera NPU using **w8a8** quantization.

This model has been optimized with the following LoRA: 

Compatible with Pulsar2 version: 6.0 115775d3

## Convert tools links:

For those who are interested in model conversion, you can try to export axmodel through 

- [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://docs.m5stack.com/en/ai_hardware/LLM-8850_Card)
  

## 性能基准测试 (Performance Benchmark)

| 模型 | 输入分辨率 | AX650板端耗时 |
|------|-----------|--------------|
| NAFNet | 256×256 | 87ms |
| DnCNN | 416×416 | 22ms |
| FFDNet | 640×640 | 19.3ms |
| FastDVDnet | 640×480 | 61.2ms |
| Restormer | 224×224 | 1600ms |

## How to use

Download all files from this repository to the device

```
模型文件组织方式如下:
.
|-- pic
|   `-- noisy.png
|-- model_convert
|   |-- NAFNet.json
|   `-- axmodel
|       `-- NAFNet_1_3_256_256.axmodel
|-- python
|   |-- axmodel_infer.py
|   `-- onnx_infer.py
`-- res
    `-- axmodel_compare.png


```

### Inference
#### Image Denoising

图片推理,执行命令`python3 axmodel_infer.py`:
```
(base) root@ax650:~/NAFNet# python3 axmodel_infer.py
[INFO] Available providers:  ['AxEngineExecutionProvider', 'AXCLRTExecutionProvider']
[INFO] Using provider: AxEngineExecutionProvider
[INFO] Chip type: ChipType.MC50
[INFO] VNPU type: VNPUType.DISABLED
[INFO] Engine version: 2.12.0s
[INFO] Model type: 2 (triple core)
[INFO] Compiler version: 6.0 115775d3
axmodel inference finished: axmodel_compare.png

```

推理结果样例:
![alt text](NAFNet/res/axmodel_compare.png)

#### Video Denoising

视频推理,执行命令`python3 axmodel_video_infer.py`:
```
(base) root@ax650:~/fastdvdnet# python3 axmodel_video_infer.py
[INFO] Available providers:  ['AxEngineExecutionProvider', 'AXCLRTExecutionProvider']
[INFO] Using provider: AxEngineExecutionProvider
[INFO] Chip type: ChipType.MC50
[INFO] VNPU type: VNPUType.DISABLED
[INFO] Engine version: 2.12.0s
[INFO] Model type: 2 (triple core)
[INFO] Compiler version: 6.0 115775d3
providers: AxEngineExecutionProvider
inputs: [('noisy', [1, 15, 480, 640], 'float32'), ('noise_map', [1, 1, 480, 640], 'float32')]
outputs: [('denoised', [1, 3, 480, 640])]
video: 854x480 @ 25.0fps, 67 frames
axmodel input: 640x480
[OK] ./people-sunset.mp4 -> ./people-sunset_axmodel_side_by_side.mp4
     frames=67 time=17.57s fps=3.81

```

视频降噪样例:

![Video Denoising Demo](fastDVDnet/res/people-sunset_axmodel_side_by_side.gif)