论文复现| Free-Form Image Inpainting with Gated Convolution

论文复现| Free-Form Image Inpainting with Gated Convolution

复现论文代码:
https://github.com/JiahuiYu/generative_inpainting

环境搭建

Readme中有详细的步骤
• Install python3.
• Install tensorflow (tested on Release 1.3.0, 1.4.0, 1.5.0, 1.6.0, 1.7.0).
• Install tensorflow toolkit neuralgym (run pip install git+https://github.com/JiahuiYu/neuralgym).
在第二步安装tensorflow时遇到不少问题:

经过互联网查询,安装方式有两种,官方给出用python pip安装,经过比较,选择使用通过Anaconda安装
参考网址:https://blog.csdn.net/Cs_hnu_scw/article/details/79695347
成功安装Anaconda
在这里插入图片描述

问题1

因为安装Tensorflow时,需要从Anaconda仓库中下载,一般默认链接的都是国外镜像地址,下载慢,
解决:所以用国内清华镜像,需要改一下链接镜像的地址。这里,我们打开刚刚安装好的Anaconda中的 Anaconda Prompt,然后输入:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/     
conda config --set show_channel_urls yes

问题2

根据Tensorflow的官方文档,通过cmd命令:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_x86_64.whl
安装时出现错误
在这里插入图片描述

问题3

通过命令:pip install --upgrade --ignore-installed tensorflow
安装时提示升级pip,
解决:根据cmd上面的提示进行命令安装就可以了

问题4

安装报错
在这里插入图片描述
原因:pip 的依赖项解析器当前未考虑安装的所有包。此行为是以下依赖项冲突的根源。
解决:重新安装PyHamcrest这两个包:pip install PyHamcrest

在这里插入图片描述

问题5

使用命令:run pip install git+https://github.com/JiahuiYu/neuralgym) 安装tensorflow toolkit neuralgym 时报错
在这里插入图片描述
原因:为没有安装git,
解决:安装git
在这里插入图片描述
在这里插入图片描述

问题6

:报错AttributeError: module ‘tensorflow’ has no attribute ‘contrib’
在这里插入图片描述
问题解析:Tensorflow2.x 版本较1.x版本有了很大的变动,以使TensorFlow用户更加高效。其中 tf.contrib 被完全弃用了是 2.x版本的一个重大的变化,但 import tensorflow.contrib.slim as slim slim 作为一个高级封装,已经在很多之前的版本中广泛使用。现在大部分的源码还是以tensorflow1.x版本为基础写的,这导致了一些已经在2.x版本中移除的模块无法使用。

解决:tensorflow版本过高,重装为tensorflow1.7

问题7

问题8:
关键包缺失
ModuleNotFoundError: No module named ‘neuralgym’
ModuleNotFoundError: No module named ‘cv2’
ModuleNotFoundError: No module named ‘yaml’
ModuleNotFoundError: No module named ‘PIL’
解决:下载包:
pip install pillow
pip install pyyaml
pip install opencv-python
pip install git+https://github.com/JiahuiYu/neuralgym

解决完问题后,运行初步成功
在这里插入图片描述

运行&训练

二:训练及运行,
Readme上有详细步骤:

  1. Training:
    o Prepare training images filelist and shuffle it (example).
    o Modify inpaint.yml to set DATA_FLIST, LOG_DIR, IMG_SHAPES and other parameters.
    o Run .python train.py
  2. Resume training:
    o ‎修改‎MODEL_RESTORE ‎标志在‎ inpaint.yml. E.g., MODEL_RESTORE: 20180115220926508503_places2_model.
    o Run .python train.py
  3. Testing:
    o Run .python test.py --image examples/input.png --mask examples/mask.png --output examples/output.png --checkpoint model_logs/your_model_dir

问题7:
train.py程序成功执行,但文件列表没有配置:
解决:在Readme中相关网址:https://github.com/JiahuiYu/generative_inpainting/issues/15
找到方法写代码来生成列表文件
结果:报错No such file or directory: ‘data/celeba_hq/train_shuffled.flist’
在这里插入图片描述

问题8:
运行train.py和文件列表生成代码都报错:No such file or directory: ‘data/celeba_hq/train_shuffled.flist’
问题分析:打开相关数据文件,得到以下数据:
“ # https://github.com/jiahuiyu/progressive_growing_of_gans_tf
celebahq: [
‘data/celeba_hq/train_shuffled.flist’,
‘data/celeba_hq/validation_static_view.flist’
]”
打开所示网址,显示404:
在这里插入图片描述
问题仍待解决
问题9:
报错:Use the retry module or similar alternatives.

关于文件列表,我找到了一个csdn的博文,其中的描述比较详细:https://blog.csdn.net/Gavinmiaoc/article/details/81250782
按其中的说法配置文件:
在这里插入图片描述
问题10:
配置文件列表时报错:FileNotFoundError: [WinError 3] 系统找不到指定的路径。: ‘/home/gavin/Dataset/celeba’
解决方法:无

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值