i'm new in deep learning, and i want make image classification project for betta fish, but i got a problem with my code while i'm use gerator to read my image, someone could help me?
from tensorflow.keras.preprocessing.image import ImageDataGenerator
# All images will be rescaled by 1./255
train_datagen = ImageDataGenerator(rescale=1./255)
# Flow training images in batches of 128 using train_datagen generator
train_generator = train_datagen.flow_from_directory(
'\\tmp\Train', # This is the source directory for training images
target_size=(300, 300), # All images will be resized to 150x150
batch_size=128,
# Since we use binary_crossentropy loss, we need binary labels
class_mode='binary')
then the error would be like this:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-24-fec6e611274c> in <module>
10 batch_size=128,
11 # Since we use binary_crossentropy loss, we need binary labels
---> 12 class_mode='binary')
~\anaconda3\lib\site-packages\keras_preprocessing\image\image_data_generator.py in flow_from_directory(self, directory, target_size, color_mode, classes, class_mode, batch_size, shuffle, seed, save_to_dir, save_prefix, save_format, follow_links, subset, interpolation)
538 follow_links=follow_links,
539 subset=subset,
--> 540 interpolation=interpolation
541 )
542
~\anaconda3\lib\site-packages\keras_preprocessing\image\directory_iterator.py in __init__(self, directory, image_data_generator, target_size, color_mode, classes, class_mode, batch_size, shuffle, seed, data_format, save_to_dir, save_prefix, save_format, follow_links, subset, interpolation, dtype)
104 if not classes:
105 classes = []
--> 106 for subdir in sorted(os.listdir(directory)):
107 if os.path.isdir(os.path.join(directory, subdir)):
108 classes.append(subdir)
FileNotFoundError: [WinError 3] The system cannot find the path specified: '\\tmp\\Train'
unless tmp is in the current directory you are in you need to specify the full path in flow_from_directory. for example
train_dir=r'c:\whatever\temp\train'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.