Noise2Noise去高斯噪声、去文本噪声

1,395 阅读3分钟

声明:本博文做了该代码的测试分享,敬请查阅;

这是一篇经典的图像去噪文章的简单测试


作者:墨理学AI

本文、节选自 图像修复专栏


基础信息



环境搭建(Cuda9.1):


cuda9.1 GTX 1080 11G


conda create -n n2n366 python=3.6.6

source activate n2n366

## tensorflow -GPU的 安装 要使用 共享的编译好的  tensorflow-1.10.1-cp36-cp36m-linux_x86_64.whl

## 使用 pip install tensorflow-1.10.1-cp36-cp36m-linux_x86_64.whl 来进行安装,安装之后 pip list 查看 显示:

tensorflow         1.10.1    ##  已经可以使用。

pip install Keras==2.1.6

pip install opencv-python

pip install pillow

pip install matplotlib

#官方代码需要 安装这俩
pip install typeguard==2.2.2
pip install nibabel==2.3.0



数据集


个人数据集:使用数据( 人证照片 ):

train 500

test 200


训练


第二种 text 噪声 加噪去噪 效果验证:


--nb_epochs 300 训练时长 15h

nohup python train.py --image_dir dataset/train --test_dir dataset/test --image_size 128 --batch_size 4 --lr 0.001 --source_noise_model text,0,50 --target_noise_model clean --val_noise_model text,0,50 --loss mae --output_path text_clean  --nb_epochs 300 &

测试

这是一个大佬的非官方实现测试;


  • 下载预训练模型:

github.com/yu4u/noise2… 0

  • 使用上面下载的预训练模型进行测试:

针对三种噪声、带噪和不带噪两种模型 的测试命令: 测试时,通过设置参数 --test_noise_model 类型,否则 默认会 添加 gaussian 噪声

python test_model.py --weight_file  weights/weights.056-4.172-28.07752_text_clean.hdf5 --image_dir dataset/commonSet --output_dir _text_clean --test_noise_model text,0,60  

python test_model.py --weight_file  weights/weights.057-4.796-27.68533_text_noise.hdf5  --image_dir dataset/commonSet --output_dir _text_noise --test_noise_model text,0,60 

python test_model.py --weight_file  weights/weights.056-66.803-30.57923_gauss_clean.hdf5  --image_dir dataset/commonSet --output_dir gaussian_clean --test_noise_model gaussian,0,60 

python test_model.py --weight_file  weights/weights.040-87.447-29.13496_gauss_noise.hdf5  --image_dir dataset/commonSet --output_dir gauss_noise --test_noise_model gaussian,0,60 


python test_model.py --weight_file  weights/weights.038-4.547-24.81654_impulse_clean.hdf5  --image_dir dataset/commonSet --output_dir impulse_clean --test_noise_model impulse,0,60 

python test_model.py --weight_file  weights/weights.047-2.317-24.30238_impulse_noise.hdf5  --image_dir dataset/commonSet --output_dir impulse_noise --test_noise_model impulse,0,60 



针对文本噪声测试效果如下:


纯净数据,加噪去噪,效果如下:

python test_model.py --weight_file text_clean/weights.300-1.180-36.05937.hdf5 --image_dir dataset/commonSet --output_dir commonSetOut --test_noise_model text,0,60 

图一:

1-5

带噪数据,不加噪,去噪 效果如下:

python test_model.py --weight_file text_clean/weights.300-1.180-36.05937.hdf5 --image_dir dataset/commonSet3 --output_dir commonSet3Out --test_noise_model clean

图二:

2


总结:


  noise2noise 300epoch训练得到的模型,可以较好的去除它本身加的随机 text 噪声,但是对于其他类型的文本噪声,并没有去噪效果。

原因如下:

  源代码中的 text噪声,虽说是随机生成的,但这些文本都是完整的数字或者字母,而图二: 下方的照片里面的噪声 种类 和 训练是 完全 不一致,因此它是没有 消除效果的。



🚀🚀 墨理学AI


  • 🎉 作为全网 AI 领域 干货最多的博主之一,❤️ 不负光阴不负卿 ❤️
  • ❤️ 如果文章对你有帮助、点赞、评论鼓励博主的每一分认真创作
  • 快乐学AI 、深度学习环境搭建 : 一文读懂

    900.png

    博主简介:软件工程硕士、已毕业、马上 10w 读者 粉丝

    • 🍊 计算机视觉:超分重建、图像修复、目标检测、风格迁移 等领域 稍有所学
    • 🍊 AI 工程化:Ncnn、MNN、TensorRT 正在 学习
    • 🍊 C++、Python、Java 略懂一二

    喜欢请关注 墨理学AI 及其 同名 公众号 墨理学AI

    取经路上,让墨理学AI 陪你畅享更多有趣AI