Exception error when executing tensorflow

Asked 2 years ago, Updated 2 years ago, 61 views

I'm a python beginner.When I ran Taehoon Kim's tensorflow (1.13.1) Image auto-generated demo, I got the following error:I would appreciate it if you could let me know.

File "main.py", line 103, in<module>
 tf.app.run()
File"/anaconda3/envs/tensorflow/lib/python 3.5/site-packages/tensorflow/python/platform/app.py", line 125, in run
 _sys.exit(main(argv))
File "main.py", line81, in main
 data_dir=FLAGS.data_dir)
File "/Users/ina/model.py", line81, in_init__
 raise Exception("[!] No data found in '''+data_path+'''')
Exception: ! No data found in'./data/celebA/*.jpg'  
importos
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 closed).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 data [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  


defmain(_):  
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 notos.path.exists(FLAGS.checkpoint_dir):  
os.madeirs (FLAGS.checkpoint_dir)  
if notos.path.exists(FLAGS.sample_dir):  
os.madeirs (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) asess:  
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()

python tensorflow

2022-09-30 20:19

1 Answers

First, we moved the corresponding data (celebA) in the image to the data folder and then ran it after Pillow installation.
I still got an error, but once I deleted the code and tried again, it succeeded.
Thank you for your comment.


2022-09-30 20:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.