Skip to content

Commit acf1f5d

Browse files
authored
Examples (a2q): adding links for pretrained models (#707)
1 parent 2cbdb8c commit acf1f5d

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed

src/brevitas_examples/super_resolution/README.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Integer-Quantized Super Resolution Experiments with Brevitas
22

3-
This directory contains scripts demonstrating how to train integer-quantized super resolution models using [Brevitas](https://github.com/Xilinx/brevitas).
3+
This directory contains scripts demonstrating how to train integer-quantized super resolution models using Brevitas.
44
Code is also provided to demonstrate accumulator-aware quantization (A2Q) as proposed in our ICCV 2023 paper "[A2Q: Accumulator-Aware Quantization with Guaranteed Overflow Avoidance](https://arxiv.org/abs/2308.13504)".
55

66
## Experiments
@@ -12,25 +12,32 @@ During inference center cropping is applied.
1212
Inputs are then downscaled by 2x and then used to train the model directly in the RGB space.
1313
Note that this is a difference from many academic works that train only on the Y-channel in YCbCr format.
1414

15-
| Model Name | Upscale Factor | Weight quantization | Activation quantization | Peak Signal-to-Noise Ratio |
15+
| Model Name | Upscale Factor | Weight quantization | Activation quantization | Peak Signal-to-Noise Ratio |
1616
|-----------------------------|----------------|---------------------|-------------------------|----------------------------|
17-
| bicubic_interp | x2 | N/A | N/A | 28.71 |
18-
| [float_espcn_x2]() | x2 | float32 | float32 | 31.03 |
17+
| bicubic_interp | x2 | N/A | N/A | 28.71 |
18+
| [float_espcn_x2](https://github.com/Xilinx/brevitas/releases/download/super_res_r1/float_espcn_x2-2f85a454.pth) | x2 | float32 | float32 | 31.03 |
1919
||
20-
| [quant_espcn_x2_w8a8_base]() | x2 | int8 | (u)int8 | 30.96 |
21-
| [quant_espcn_x2_w8a8_a2q_32b]() | x2 | int8 | (u)int8 | 30.79 |
22-
| [quant_espcn_x2_w8a8_a2q_16b]() | x2 | int8 | (u)int8 | 30.56 |
20+
| [quant_espcn_x2_w8a8_base](https://github.com/Xilinx/brevitas/releases/download/super_res_r1/quant_espcn_x2_w8a8_base-f761e4a1.pth) | x2 | int8 | (u)int8 | 30.96 |
21+
| [quant_espcn_x2_w8a8_a2q_32b](https://github.com/Xilinx/brevitas/releases/download/super_res_r1/quant_espcn_x2_w8a8_a2q_32b-85470d9b.pth) | x2 | int8 | (u)int8 | 30.79 |
22+
| [quant_espcn_x2_w8a8_a2q_16b](https://github.com/Xilinx/brevitas/releases/download/super_res_r1/quant_espcn_x2_w8a8_a2q_16b-f9e1da66.pth) | x2 | int8 | (u)int8 | 30.56 |
2323
||
24-
| [quant_espcn_x2_w4a4_base]() | x2 | int4 | (u)int4 | 30.30 |
25-
| [quant_espcn_x2_w4a4_a2q_32b]() | x2 | int4 | (u)int4 | 30.27 |
26-
| [quant_espcn_x2_w4a4_a2q_13b]() | x2 | int4 | (u)int4 | 30.24 |
24+
| [quant_espcn_x2_w4a4_base](https://github.com/Xilinx/brevitas/releases/download/super_res_r1/quant_espcn_x2_w4a4_base-80658e6d.pth) | x2 | int4 | (u)int4 | 30.30 |
25+
| [quant_espcn_x2_w4a4_a2q_32b](https://github.com/Xilinx/brevitas/releases/download/super_res_r1/quant_espcn_x2_w4a4_a2q_32b-8702a412.pth) | x2 | int4 | (u)int4 | 30.27 |
26+
| [quant_espcn_x2_w4a4_a2q_13b](https://github.com/Xilinx/brevitas/releases/download/super_res_r1/quant_espcn_x2_w4a4_a2q_13b-9fff234e.pth) | x2 | int4 | (u)int4 | 30.24 |
2727

2828

2929
## Train
3030

31-
To start training a model from scratch (*e.g.*, `quant_espcn_x2_w8a8_a2q_32b`) run:
31+
All models are trained from scratch as follows:
3232
```bash
33-
python train_model.py --data_root=data --model=quant_espcn_x2_w8a8_a2q_32b
33+
python train_model.py^
34+
--data_root=./data^
35+
--model=quant_espcn_x2_w8a8_a2q_32b^
36+
--batch_size=8^
37+
--learning_rate=0.001^
38+
--weight_decay=0.00001^
39+
--gamma=0.999^
40+
--step_size=1
3441
```
3542

3643
## Evaluate

src/brevitas_examples/super_resolution/models/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,16 @@
4545
act_bit_width=4,
4646
acc_bit_width=13)}
4747

48-
root_url = 'https://github.com/Xilinx/brevitas/releases/download/super_res-r0'
48+
root_url = 'https://github.com/Xilinx/brevitas/releases/download/super_res_r1'
4949

5050
model_url = {
51-
'float_espcn_x2': f'{root_url}/float_espcn_x2-2f3821e3.pth',
52-
'quant_espcn_x2_w8a8_base': f'{root_url}/quant_espcn_x2_w8a8_base-7d54e29c.pth',
53-
'quant_espcn_x2_w8a8_a2q_32b': f'{root_url}/quant_espcn_x2_w8a8_a2q_32b-0b1f361d.pth',
54-
'quant_espcn_x2_w8a8_a2q_16b': f'{root_url}/quant_espcn_x2_w8a8_a2q_16b-3c4acd35.pth'}
51+
'float_espcn_x2': f'{root_url}/float_espcn_x2-2f85a454.pth',
52+
'quant_espcn_x2_w4a4_a2q_13b': f'{root_url}/quant_espcn_x2_w4a4_a2q_13b-9fff234e.pth',
53+
'quant_espcn_x2_w4a4_a2q_32b': f'{root_url}/quant_espcn_x2_w4a4_a2q_32b-8702a412.pth',
54+
'quant_espcn_x2_w4a4_base': f'{root_url}/quant_espcn_x2_w4a4_base-80658e6d.pth',
55+
'quant_espcn_x2_w8a8_a2q_16b': f'{root_url}/quant_espcn_x2_w8a8_a2q_16b-f9e1da66.pth',
56+
'quant_espcn_x2_w8a8_a2q_32b': f'{root_url}/quant_espcn_x2_w8a8_a2q_32b-85470d9b.pth',
57+
'quant_espcn_x2_w8a8_base': f'{root_url}/quant_espcn_x2_w8a8_base-f761e4a1.pth'}
5558

5659

5760
def get_model_by_name(name: str, pretrained: bool = False) -> Union[FloatESPCN, QuantESPCN]:

0 commit comments

Comments
 (0)