0

python初心者です。Taehoon Kim氏のtensorflow(1.13.1) 画像自動生成デモ を実行したところ、以下のエラーが出てしまいました。ご教授頂けましたら幸いです。

File "main.py", line 103, in <module>
 tf.app.run()
File "/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
 _sys.exit(main(argv))
File "main.py", line 81, in main
 data_dir=FLAGS.data_dir)
File "/Users/ina/model.py", line 81, in __init__
 raise Exception("[!] No data found in '" + data_path + "'")
Exception: [!] No data found in './data/celebA/*.jpg'  
import os
import scipy.misc
import numpy as np

from model import DCGAN
from utils import pp, visualize, to_json, show_all_variables

import tensorflow as tf

flags = tf.app.flags
flags.DEFINE_integer("epoch", 25, "Epoch to train [25]")
flags.DEFINE_float("learning_rate", 0.0002, "Learning rate of for adam [0.0002]")
flags.DEFINE_float("beta1", 0.5, "Momentum term of adam [0.5]")
flags.DEFINE_float("train_size", np.inf, "The size of train images [np.inf]")
flags.DEFINE_integer("batch_size", 64, "The size of batch images [64]")```  
flags.DEFINE_integer("input_height", 108, "The size of image to use (will be center cropped). [108]")  
flags.DEFINE_integer("input_width", None, "The size of image to use (will be center cropped). If None, same value as input_height [None]")  
flags.DEFINE_integer("output_height", 64, "The size of the output images to produce [64]")  
flags.DEFINE_integer("output_width", None, "The size of the output images to produce. If None, same value as output_height [None]")  
flags.DEFINE_string("dataset", "celebA", "The name of dataset [celebA, mnist, lsun]")  
flags.DEFINE_string("input_fname_pattern", "*.jpg", "Glob pattern of filename of input images [*]")  
flags.DEFINE_string("checkpoint_dir", "checkpoint", "Directory name to save the checkpoints [checkpoint]")  
flags.DEFINE_string("data_dir", "./data", "Root directory of dataset [data]")  
flags.DEFINE_string("sample_dir", "samples", "Directory name to save the image samples [samples]")  
flags.DEFINE_boolean("train", False, "True for training, False for testing [False]")  
flags.DEFINE_boolean("crop", False, "True for training, False for testing [False]")  
flags.DEFINE_boolean("visualize", False, "True for visualizing, False for nothing [False]")  
flags.DEFINE_integer("generate_test_images", 100, "Number of images to generate during test. [100]")  
FLAGS = flags.FLAGS  


def main(_):  
pp.pprint(flags.FLAGS.__flags)  

if FLAGS.input_width is None:  
FLAGS.input_width = FLAGS.input_height  
if FLAGS.output_width is None:  
FLAGS.output_width = FLAGS.output_height  

if not os.path.exists(FLAGS.checkpoint_dir):  
os.makedirs(FLAGS.checkpoint_dir)  
if not os.path.exists(FLAGS.sample_dir):  
os.makedirs(FLAGS.sample_dir)  

gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333)  
run_config = tf.ConfigProto()  
run_config.gpu_options.allow_growth=True  

with tf.Session(config=run_config) as sess:  
if FLAGS.dataset == 'mnist':  
dcgan = DCGAN(  
sess,  
input_width=FLAGS.input_width,  
input_height=FLAGS.input_height,  
output_width=FLAGS.output_width,  
output_height=FLAGS.output_height,  
batch_size=FLAGS.batch_size,  
sample_num=FLAGS.batch_size,  
y_dim=10,  
z_dim=FLAGS.generate_test_images,  
dataset_name=FLAGS.dataset,  
input_fname_pattern=FLAGS.input_fname_pattern,  
crop=FLAGS.crop,  
checkpoint_dir=FLAGS.checkpoint_dir,  
sample_dir=FLAGS.sample_dir,  
data_dir=FLAGS.data_dir )  
else:  
dcgan = DCGAN(  
sess,  
input_width=FLAGS.input_width,  
input_height=FLAGS.input_height,  
output_width=FLAGS.output_width,  
output_height=FLAGS.output_height,  
batch_size=FLAGS.batch_size,  
sample_num=FLAGS.batch_size,  
z_dim=FLAGS.generate_test_images,  
dataset_name=FLAGS.dataset,  
input_fname_pattern=FLAGS.input_fname_pattern,  
crop=FLAGS.crop,  
checkpoint_dir=FLAGS.checkpoint_dir,  
sample_dir=FLAGS.sample_dir,  
data_dir=FLAGS.data_dir)  

show_all_variables()  

if FLAGS.train:  
dcgan.train(FLAGS)  
else:  
if not dcgan.load(FLAGS.checkpoint_dir)[0]:  
raise Exception("[!] Train a model first, then run test mode")  


to_json("./web/js/layers.js", [dcgan.h0_w, dcgan.h0_b, dcgan.g_bn0],  
[dcgan.h1_w, dcgan.h1_b, dcgan.g_bn1],  
[dcgan.h2_w, dcgan.h2_b, dcgan.g_bn2],  
[dcgan.h3_w, dcgan.h3_b, dcgan.g_bn3],  
[dcgan.h4_w, dcgan.h4_b, None])  

Below is codes for visualization  
OPTION = 1  
visualize(sess, dcgan, FLAGS, OPTION)  

if __name__ == '__main__':  
tf.app.run()
4
  • 2
    './data/celebA/*.jpg' が存在しないというエラーのようですが、該当するファイルは存在しますか? / 画像自動生成デモについて、出典URLなどあると回答が得られやすくなるかと存じます。
    – PicoSushi
    2019年3月26日 1:59
  • PicoSushiさん ご回答頂き、有難うございます。ご指摘の通りcelebAの場所を変更したところ、処理が多少進んだのですがまた新たにAttributeError: module 'scipy.misc' has no attribute 'imresize'と出てしましました。。調べて解決したいと思います。また、出展URLの添付等の親切なご指摘も重ねて感謝します。
    – archi
    2019年3月26日 4:06
  • おそらく、pythonの画像解析ライブラリである「Pillow」がインストールされていないんだと思います。インストール方法などは開発環境にもよると思うので、調べてみてください。
    – blank
    2019年3月26日 5:01
  • 1
    champonさん ご指摘有難うございます。早速Pillowをインストールし実行した所、他の箇所でエラーが発生してしまったのですが、一度全て削除し再度試した所、正常に実行することができました。有難うございます!これからも色々試して行きたいです。
    – archi
    2019年3月26日 23:41

1 件の回答 1

1

まず、画像の該当データ(celebA)をdataフォルダーに移動し、次にPillowインストール後実行しました。
それでもエラーが出てしまったのですが、一度コードを削除し再度実行したところ成功しました。
コメント頂き有難うございました。

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。