粗到细策略已广泛用于单图像去模糊网络的架构设计。传统方法通常使用多尺度输入图像来堆叠子网络,并从底部子网络到顶部子网络逐渐提高图像的清晰度,不可避免地会产生较高的计算成本。为了实现快速准确的去模糊网络设计,我们重新审视了从粗到精的策略,并提出了一种多输入多输出U网(MIMO UNet)。首先,MIMO UNet的单个编码器采用多尺度输入图像,以减轻训练的难度。其次,MIMO UNet的单个解码器输出多个不同尺度的去模糊图像,以模拟使用单个U形网络的多级联U形网络。最后,引入非对称特征融合,有效地融合多尺度特征。在GoPro和RealBlur数据集上进行的大量实验表明,所提出的网络在精度和计算复杂性方面都优于最先进的方法。
文献: Rethinking Coarse-to-Fine Approach in Single Image Deblurring.
MIMO UNet的架构基于单个U-Net,对其进行了重大修改,以实现高效的多尺度去模糊。MIMO UNet的编码器和解码器由三个编码器块(EB)和解码器块(DB)组成,它们使用卷积层从不同阶段提取特征。
数据集链接 (谷歌云盘): GOPRO_Large
提出了GOPRO_Large数据集用于动态场景去模糊。培训和测试集是公开的。
.
└─ GOPRO_Large
├─ train
│ ├─ GOPR0xxx_xx_xx
│ │ ├─ blur
│ │ │ ├─ ***.png
│ │ │ └─ ...
│ │ ├─ blur_gamma
│ │ │ ├─ ***.png
│ │ │ └─ ...
│ │ ├─ sharp
│ │ │ ├─ ***.png
│ │ │ └─ ...
│ │ └─ frames X offset X.txt
│ └─ ...
└─ test
├─ GOPR0xxx_xx_xx
│ ├─ blur
│ │ ├─ ***.png
│ │ └─ ...
│ ├─ blur_gamma
│ │ ├─ ***.png
│ │ └─ ...
│ └─ sharp
│ ├─ ***.png
│ └─ ...
└─ ...
下载数据集后,运行preprocessing.py
脚本位于文件夹src
中。下面是下载的数据集的文件结构。
参数描述:
--root_src
- Path to the original dataset root, containing train/
and test/
folders.--root_dst
- Path to the directory, where the pre-processed dataset will be stored.python src/preprocessing.py --root_src /path/to/original/dataset/root --root_dst /path/to/preprocessed/dataset/root
在上面的示例中,执行测试脚本后,预处理的图像将存储在/path/to/preprocessed/datasets/root路径下。下面是预处理数据集的文件结构。
.
└─ GOPRO_preprocessed
├─ train
│ ├─ blur
│ │ ├─ 1.png
│ │ ├─ ...
│ │ └─ 2103.png
│ └─ sharp
│ ├─ 1.png
│ ├─ ...
│ └─ 2103.png
└─ test
├─ blur
│ ├─ 1.png
│ ├─ ...
│ └─ 1111.png
└─ sharp
├─ 1.png
├─ ...
└─ 1111.png
硬件 (GPU)
框架
有关详细信息,请参阅以下资源:
额外python包:
手动安装其他软件包或使用pip Install-r requirements。txt
命令
通过官方网站和其他软件包安装MindSpore后,您可以按照以下方式开始培训和评估:
在GPU上运行
# 运行训练例子
python ./train.py --dataset_root /path/to/dataset/root --ckpt_save_directory /save/checkpoint/directory
# 或者
bash scripts/run_standalone_train_gpu.sh /path/to/dataset/root /save/checkpoint/directory
# 运行分布式训练例子
bash scripts/run_distribute_train_gpu.sh /path/to/dataset/root /save/checkpoint/directory
# 运行评测例子
python ./eval.py --dataset_root /path/to/dataset/root \
--ckpt_file /path/to/eval/checkpoint.ckpt \
--img_save_directory /path/to/result/images
# 或者
bash scripts/run_eval_gpu.sh /path/to/dataset/root /path/to/eval/checkpoint.ckpt /path/to/result/images
.
└─ cv
└─ MIMO-UNet
├── configs
├── gpu_config.yaml # Config for training on GPU
├── scripts
├── run_distribute_train_gpu.sh # Distributed training on GPU shell script
├── run_standalone_train_gpu.sh # Shell script for single GPU training
├── run_eval_gpu.sh # GPU evaluation script
├─ src
├─ data_augment.py # Augmentation
├─ data_load.py # Dataloader
├─ init_weights.py # Weights initializers
├─ layers.py # Model layers
├─ loss.py # Loss function
├─ metric.py # Metrics
├─ mimo_unet.py # MIMO-UNet architecture
├─ preprocessing.py
├─ eval.py # test script
├─ train.py # train script
├─ export.py # export script
├─ requirements.txt # requirements file
└─ README.md # MIMO-UNet file English description
在GPU上运行
参数描述:
--dataset_root
- 数据集根目录的路径,包含train/
和test/
文件夹--ckpt_save_directory
- 输出目录,其中存储来自训练过程的数据python ./train.py --dataset_root /path/to/dataset/root --ckpt_save_directory /save/checkpoint/directory
# or
bash scripts/run_standalone_train_gpu.sh [DATASET_PATH] [OUTPUT_CKPT_DIR]
train/
和test/
文件夹Running on GPU
bash scripts/run_distribute_train_gpu.sh [DATASET_PATH] [OUTPUT_CKPT_DIR]
train/
和test/
文件夹计算PSNR度量并保存去模糊图像
评估时,选择最后生成的检查点,并将其传递给验证脚本的相应参数
在GPU上运行
参数描述:
--dataset_root
- 数据集根目录的路径,包含train/
和test/
文件夹--ckpt_file
- 包含训练模型权重的检查点路径--img_save_directory
- 输出目录,其中将存储验证过程中的图像。可选参数,如果未指定,则不会保存验证图像python ./eval.py --dataset_root /path/to/dataset/root \
--ckpt_file /path/to/eval/checkpoint.ckpt \
--img_save_directory /path/to/result/images # save validation images
# 或者
python ./eval.py --dataset_root /path/to/dataset/root \
--ckpt_file /path/to/eval/checkpoint.ckpt # don't save validation images
# 或者
bash scripts/run_eval_gpu.sh [DATASET_PATH] [CKPT_PATH] [SAVE_IMG_DIR] # save validation images
# 或者
bash scripts/run_eval_gpu.sh [DATASET_PATH] [CKPT_PATH] # don't save validation images
train/
和test/
文件夹After the test script is executed, the deblured images are stored in /path/to/result/img/
if the path was specified.
python export.py --ckpt_file /path/to/mimounet/checkpoint.ckpt --export_device_target GPU --export_file_format MINDIR
脚本将在当前目录中生成相应的MINDIR文件。
参数 | MIMO-UNet (1xGPU) |
---|---|
模型版本 | MIMO-UNet |
硬件资源 | GPU: 1*A100, CPU: 8, |
更新日期 | 10 / 15 / 2022 (month/day/year) |
MindSpore版本 | 1.8.1 |
数据集 | GOPRO_Large |
训练参数 | batch_size=16, lr=0.000001 and bisected every 500 epochs |
优化器 | Adam |
输出 | images |
速度 | 132 ms/step |
总时间 | 1d 14h 13m |
ckpt文件 | 26MB(.ckpt file) |
参数 | MIMO-UNet (1xGPU) |
---|---|
模型版本 | MIMO-UNet |
硬件资源 | GPU: 1*A100, CPU: 8 |
更新时间 | 10 / 15 / 2022 (month/day/year) |
MindSpore版本 | 1.8.1 |
数据集 | GOPRO_Large |
测试批次大小 | 1 |
输出 | images |
PSNR精度 | 1p: 31.55 |
在训练脚本,我们在“train”函数中设置随机数种子
请查看仓库 homepage
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》