|
Download samples/eagle_4x/README.md from HelloSun/Real-ESRGAN-OpenVINO: direct link, hf CLI and curl.
- Browser
- Download file 4.51 kB
-
https://huggingface.co/HelloSun/Real-ESRGAN-OpenVINO/resolve/main/samples/eagle_4x/README.md
- Command line
-
hf download hf://HelloSun/Real-ESRGAN-OpenVINO/samples/eagle_4x/README.md
-
curl -L -o README.md https://huggingface.co/HelloSun/Real-ESRGAN-OpenVINO/resolve/main/samples/eagle_4x/README.md
4.51 kB
效果對比:白頭海雕(Bald Eagle)
這個資料夾是 同一張低解析度照片 經過「原始 PyTorch 模型」與「所有 OpenVINO 量化版本」後的結果, 可以直接看出各種精度的差別。
來源與授權
| 項目 | 內容 |
|---|---|
| 照片 | NASA Kennedy Space Center, Baby Eagle in the Rain(2023-04-25) |
| 原始檔 | input/nasa_bald_eagle_KSC-20230425-PH-JBS02_0003.jpg(1280×853) |
| 來源頁面 | https://images.nasa.gov/details/KSC-20230425-PH-JBS02_0003 |
| 授權 | 公有領域(Public Domain) — NASA 媒體 generally are not subject to copyright |
NASA 使用條款:https://www.nasa.gov/nasa-brand-center/images-and-media/ 本 repo 僅取用其中一張照片作為轉換/量化效果的展示素材。
測試設定
- 從原照片裁切
1024×768當作 Ground Truth(HR) - 用 bicubic 降 4 倍得到 **輸入 LR:
256×192**(00_input_lr_x4.png) - 所有模型都用 tile=128 / tile_pad=16 分塊推論,輸出
768×1024 - PyTorch 參考輸出由
tools/make_sample.py用官方RealESRGAN_x4plus.pth(params_ema)產生
檔案
| 檔案 | 說明 |
|---|---|
00_input_lr_x4.png |
模型輸入(bicubic 降 4 倍,256×192) |
01_bicubic_x4.jpg |
bicubic 上傳對照組 |
02_ground_truth.jpg |
真實 HR(未被降過的原始畫素) |
03_pytorch_fp32_reference.jpg |
原始 PyTorch 模型 FP32 輸出(基準) |
openvino_fp16.jpg |
OpenVINO FP16(與 PyTorch 幾乎一致,48.4 dB) |
openvino_int8_w8a8.jpg |
OpenVINO INT8 W8A8(27.8 dB,肉眼幾乎無差) |
openvino_int4_mixed_w4a16.jpg |
OpenVINO INT4 混合精度(22.8 dB,輕微變軟) |
openvino_int4_w4a16.jpg |
OpenVINO 純 INT4(18.0 dB,噪聲明顯) |
openvino_int4_w4a8.jpg |
OpenVINO INT4 權重 + INT8 activation(17.9 dB) |
10_detail_montage.jpg |
同一塊 320×320 細節(鷹頭 + 樹皮)的並排比較 |
metrics.json |
機讀指標 |
指標(實測)
| 模型 | 模型大小 | PSNR vs PyTorch FP32 ↑ | SSIM vs PyTorch FP32 ↑ | PSNR vs Ground Truth ↑ | 推論時間 |
|---|---|---|---|---|---|
pytorch_fp32(原始) |
67.0 MB | 基準 | 1.0000 | 20.12 dB | 4.46 s |
bicubic x4 |
– | 22.54 dB | 0.7049 | 21.70 dB | – |
openvino_fp16 |
35.1 MB | 48.38 dB | 0.9981 | 20.14 dB | 0.60 s |
openvino_int8_w8a8 |
19.5 MB | 27.76 dB | 0.8675 | 20.39 dB | 0.39 s |
openvino_int4_mixed_w4a16 |
15.2 MB | 22.84 dB | 0.8160 | 18.68 dB | 0.61 s |
openvino_int4_w4a16 |
11.0 MB | 18.02 dB | 0.4879 | 17.19 dB | 0.60 s |
openvino_int4_w4a8 |
11.8 MB | 17.89 dB | 0.4624 | 17.09 dB | 0.69 s |
(測試機:Xeon Platinum 8559C 16 vCPU、OpenVINO 2026.4.1;時間含 model 載入後的單張推論。)
怎麼看這張表
- FP16 幾乎無損:48 dB / SSIM 0.998,與原始 PyTorch 肉眼無法分辨,模型大小減半(67 → 35 MB)。
- INT8 是最佳平衡點:27.8 dB、SSIM 0.87,實測比 FP16 快約 1.5×,模型只剩 19.5 MB。
- INT4(純 4-bit) 體積最小(11 MB,比 FP32 小 6 倍),但 4-bit 誤差在 351 層殘差結構中累積, 會看到明顯的彩色雜訊(見 montage 右下),不建議用在有鑑識需求的照片上。
int4-mixed讓最敏感的層留在 INT8,畫質回到可用範圍(SSIM 0.82),只比純 INT4 多 38% 體積。- 對 HR 的 PSNR 只有 ~20 dB 是正常的:Real-ESRGAN 是針對真實退化訓練的 GAN,輸出偏「銳化/有創意」, 用 PSNR 衡量 SR 品質向來偏低,重點請看同一組模型之間的相對差異(PSNR vs PyTorch 那一欄)。
重現這個資料夾
pip install torch onnx nncf openvino opencv-python numpy
# 1) 原始 PyTorch 權重(67 MB,不進本 repo)
mkdir -p weights && curl -L -o weights/RealESRGAN_x4plus.pth \
https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth
# 2) 產生整個 samples/eagle_4x(含 PyTorch 參考輸出、各 IR 輸出、montage、metrics.json)
python tools/make_sample.py # 需要 models/ 底下已備妥各個 IR
# 權重放在別的位置時:
REALESRGAN_PTH=/path/to/RealESRGAN_x4plus.pth python tools/make_sample.py
montage 的取樣區塊寫在 build_montage()(預設 y=400, x=620, 320×320,即鷹頭與樹皮),
tiled() 用的是與 realesrgan_ov.RealESRGAN 相同的 tile=128 / tile_pad=16 分塊邏輯。