模型名称: MidnightRunner/Misc (4x-UltraSharp variant)
模型链接: HuggingFace
模型描述: 4x-UltraSharp 是基于 ESRGAN 架构的超分辨率模型,使用 23 个 RRDB(残差密集残差块)进行 4 倍图像超分辨率重建。属于 MidnightRunner/Misc 工具箱中的 UltraSharp 变体。
模型架构: ESRGAN (Enhanced Super-Resolution Generative Adversarial Network)
参数规模: 16,697,987 (16.7M)
输入规格:
输出规格:
| 依赖项 | 版本要求 | 说明 |
|---|---|---|
| Python | >= 3.10 | 推荐 3.11 |
| torch | >= 2.1.0 | PyTorch 框架 |
| torch_npu | >= 2.1.0 | 昇腾 NPU 后端 |
| Pillow | >= 9.0 | 图像处理 |
| numpy | >= 1.20 | 数组处理 |
| 昇腾驱动 | CANN 8.0+ | 推荐 CANN 8.5.1 |
安装命令:
pip install torch_npu pillow numpy# 检查 NPU 设备
npu-smi info
# 验证 torch_npu
python3 -c "import torch_npu; print(torch.npu.device_count(), torch.npu.get_device_name(0))"从 MidnightRunner/Misc 仓库下载 4x-UltraSharp.pth:
wget https://ai.gitcode.com/hf_mirrors/MidnightRunner/Misc/resolve/main/4x-UltraSharp.pth# 单张图片推理
python3 inference.py --model-path 4x-UltraSharp.pth --image input.png
# 批量推理
python3 inference.py --model-path 4x-UltraSharp.pth --input-dir ./inputs --output-dir ./outputs| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| --model-path | str | 必填 | 4x-UltraSharp.pth 路径 |
| --image | str | None | 输入图片路径 |
| --input-dir | str | None | 批量输入目录 |
| --output-dir | str | /tmp/esrgan_output | 输出目录 |
| --device | int | 0 | NPU 设备编号 |
[设备] torch_npu=2.9.0.post1+gitee7ba04, device=npu:0
[模型] 加载 4x-UltraSharp ESRGAN 权重...
[模型] 加载完成 (312ms), 参数量: 16,697,987
[数据] 生成测试图像: /tmp/test_input.png (64x64)
[输入] 64x64
[输出] 256x256, 耗时=149.7ms
[文件] 保存至: /tmp/esrgan_output/result_4x.png
[状态] SUCCESS运行命令:
python3 inference.py --model-path 4x-UltraSharp.pth输出:
[输入] 64x64 (测试图)
[输出] 256x256, 耗时=149.7ms
[状态] SUCCESS


测试数据: 合成梯度测试图 (64x64)
评测指标:
| 指标 | 结果 |
|---|---|
| 输入尺寸 | 64×64 |
| 输出尺寸 | 256×256 (4x) |
| 推理耗时 | ~150ms (npu:0) |
| 参数量 | 16,697,987 |
评测命令:
python3 inference.py --model-path 4x-UltraSharp.pth无