首页 >> 大全

TecoGAN图像增强

2023-11-26 大全 16 作者:考证青年

环境 简介

是一个基于 GAN 的自监督学习的图像增强器,也就是能让原来模糊的图像变得清晰,Teco 是 的缩写。原作者的介绍视频地址:,论文地址:

从官方给出的效果图来看,非常的惊艳。

项目体验

下载源码

git clone https://github.com/thunil/TecoGAN.git
cd TecoGAN

安装依赖

# 要求1.8以上,太高也会报错
pip install tensorflow-gpu==1.15.0
pip install -r requirements.txt

下载模型及数据

python runGAN.py 0

开始推理

python runGAN.py 1

默认处理文件夹 LR/,处理后的结果存放于文件夹 / 下

使用自己的素材

图像增强和图像复原的区别__图像增强的方法有哪些

目前只支持图片,所以是视频的话,就需要将其转成图片序列,放在一个文件夹内如 test,然后将文件夹 test 放到目录 LR下,修改文件 .py

elif( runcase == 1 ): # inference a trained modeldirstr = './results/' # the place to save the results# 由默认的calendar改为test# testpre = ['calendar'] # the test casestestpre = ['test'] # the test casesif (not os.path.exists(dirstr)): os.mkdir(dirstr)# run these test cases one by one:for nn in range(len(testpre)):cmd1 = ["python3", "main.py","--cudaID", "0",            # set the cudaID here to use only one GPU"--output_dir",  dirstr,    # Set the place to put the results."--summary_dir", os.path.join(dirstr, 'log/'), # Set the place to put the log."--mode","inference","--input_dir_LR", os.path.join("./LR/", testpre[nn]),   # the LR directory#"--input_dir_HR", os.path.join("./HR/", testpre[nn]),  # the HR directory# one of (input_dir_HR,input_dir_LR) should be given"--output_pre", testpre[nn], # the subfolder to save current scene, optional"--num_resblock", "16",  # our model has 16 residual blocks,# the pre-trained FRVSR and TecoGAN mini have 10 residual blocks"--checkpoint", './model/TecoGAN',  # the path of the trained model,"--output_ext", "png"               # png is more accurate, jpg is smaller]mycall(cmd1).communicate()

从上面的代码片段,可以看出,其原理是通过系统调用的方式去处理每一张图片,具体的逻辑实现是在文件 main.py 中

然后执行

python runGAN.py

处理后的图片存放在目录 /test 下

遇到的坑

基本上都是版本差异而引起的问题

问题一

"ImportError: cannot import name 'export_saved_model' from 'tensorflow.python.keras.saving.saved_model'"

这个一般是由于安装了多个版本引起,需要先卸载干净,然后安装对应版本

pip uninstall tensorflow-gpu
pip install tensorflow-gpu==1.15.0

问题二

ImportError: cannot import name ‘get_config’ from ‘tensorflow.python.eager.context’

修改文件 lib/ops.py,将 keras 改为 from keras

问题三

ModuleNotFoundError: No module named ‘tensorflow.contrib’

从 1.15版本后将 . 移除,可安装 1.14版本

pip install tensorflow-gpu==1.15.0

问题四

AttributeError: module 'tensorflow' has no attribute 'set_random_seed'

修改文件 main.py,将 tf.(1234) 改为 tf..(1234)

ImportError: cannot import name 'compare_ssim' from 'skimage.measure'

这是版本更新后的 api 变化引起的

解决方法是安装较低版本,如0.16.2

pip install -U scikit-image==0.16.2

numpy

NotImplementedError: Cannot convert a symbolic Tensor (2nd_target:0) to a numpy array

这里要求 numpy 版本不要过高

pip install numpy==1.19.5

wget

'wget' 不是内部或外部命令,也不是可运行的程序

如果是 系统,默认是没有 wget 工具的,工程中会使用它来下载数据包。下载地址 ,然后将下载后的可执行 exe 文件拷贝到目录 C:\\

参考资料 知识星球

新开的知识星球,目标每日更新。分享各种学习资源、实战项目、付费项目、私活分享、资源对接、行业资讯等,欢迎扫码加入

关于我们

最火推荐

小编推荐

联系我们


版权声明:本站内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 88@qq.com 举报,一经查实,本站将立刻删除。备案号:桂ICP备2021009421号
Powered By Z-BlogPHP.
复制成功
微信号:
我知道了