DCGAN-tensorflow使用经历

DCGAN-tensorflow使用经历

原网站:https://github.com/carpedm20/DCGAN-tensorflow

1.使用官方训练集

坑:

命令:python download.py mnist celebA

celebA数据库下载,众所周知的原因,需要自己想办法。
mnist在下载好一个文件之后报错,不多说直接留下网盘自己下载

链接:https://pan.baidu.com/s/13FlJTDrV4tAf_vl8N1GzCA
提取码:x7ww

下载之后四个文件

train-images-idx3-ubyte.gz
train-labels-idx1-ubyte.gz
t10k-images-idx3-ubyte.gz
t10k-labels-idx1-ubyte.gz

下载好之后的文件夹关系是:
DCGAN-tensorflow-master>data>celebA,mnist
celebA>一堆人脸图片
mnist>四个文件

这里又遇到一个坑,解包之后文件名字“-”自动变成“.”
例如:train-images-idx3.ubyte.gz
可能是我使用windows,7z解压的锅。
四个都分别手动改回来例如train-images-idx3-ubyte之后成功。

命令:python main.py --dataset mnist --input_height=28 --output_height=28 --train

Python报错 module ‘scipy.misc’ has no attribute ‘imsave’
是因为scipy版本过高,pip uninstall scipy卸载scipy,然后conda install scipy==1.2.0,成功。

2.使用自定义数据集(二次元头像自动生成)

参考:https://blog.csdn.net/mozf881/article/details/83592977

命令

python main.py --dataset faces --input_height 96 --input_width 96 --output_height 48 --output_width 48 --crop --train --epoch 20 --input_fname_pattern "*.jpg"

坑:
问题全部出在:utils.py这个文件

TypeError: Cannot handle this data type

line 94, in center_crop()
im = Image.fromarray(x[j:j+crop_h, i:i+crop_w])
改成:
im = Image.fromarray(np.uint8(x[j:j+crop_h, i:i+crop_w]))

NameError: name ‘PIL’ is not defined

在上面import PIL,不解释了

TypeError: data type not understood

line 95, in center_crop()
return np.array(im.resize([resize_h, resize_w]), PIL.Image.BILINEAR)
改成:
return np.array(im.resize([resize_h, resize_w], PIL.Image.BILINEAR))

PIL.Image.BILINEAR应该是im.resize的参数才对,括号位置有问题。

UnboundLocalError: local variable ‘im’ referenced before assignment

line 105, in transform()
return np.array(im.resize([resize_h, resize_w]), PIL.Image.BILINEAR)/127.5 - 1.

改成:
return cropped_image/127.5 - 1.

明明上面定义了cropped_image变量却没用。

改了这些就成功运行了

训练100个周期之后的效果:
100周期

  • 16
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 12
    评论
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值