When I run the code line 'Xtest, ytest = test_generator.getitem(0)' in segmentation pipeline.ipynb, I get FileNotFoundError. Although, I sorted the dataset after downloading it. Once it says, img-98.png is not a file, sometimes another file name, and then at times it says list out of index if I comment this 'Xtest, ytest = test_generator.getitem(0', and run this code line deep down 'history = model.fit(train_generator, shuffle =True,
epochs=50, workers=4, use_multiprocessing=True,
validation_data = test_generator,
verbose = 1, callbacks = callbacks)
#plotting history
plot_training_history(history)'
If I run the second code line, the error is as follows:
FileNotFoundError Traceback (most recent call last)
/var/folders/q2/2l3cmy9d7ws6npzjdp68gcbm0000gn/T/ipykernel_64715/3593073851.py in
2 epochs=50, workers=4, use_multiprocessing=True,
3 validation_data = test_generator,
----> 4 verbose = 1, callbacks = callbacks)
5 #plotting history
6 plot_training_history(history)
~/PycharmProjects/myvenv/lib/python3.7/site-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
1145 use_multiprocessing=use_multiprocessing,
1146 shuffle=shuffle,
-> 1147 initial_epoch=initial_epoch)
1148
1149 # Case 2: Symbolic tensors or Numpy array-like.
~/PycharmProjects/myvenv/lib/python3.7/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
89 warnings.warn('Update your ' + object_name + '
call to the ' +
90 'Keras 2 API: ' + signature, stacklevel=2)
---> 91 return func(*args, **kwargs)
92 wrapper._original_function = func
93 return wrapper
~/PycharmProjects/myvenv/lib/python3.7/site-packages/keras/engine/training.py in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
1730 use_multiprocessing=use_multiprocessing,
1731 shuffle=shuffle,
-> 1732 initial_epoch=initial_epoch)
1733
1734 @interfaces.legacy_generator_methods_support
~/PycharmProjects/myvenv/lib/python3.7/site-packages/keras/engine/training_generator.py in fit_generator(model, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, validation_freq, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)
183 batch_index = 0
184 while steps_done < steps_per_epoch:
--> 185 generator_output = next(output_generator)
186
187 if not hasattr(generator_output, 'len'):
~/PycharmProjects/myvenv/lib/python3.7/site-packages/keras/utils/data_utils.py in get(self)
623 except Exception:
624 self.stop()
--> 625 six.reraise(*sys.exc_info())
626
627
~/PycharmProjects/myvenv/lib/python3.7/site-packages/six.py in reraise(tp, value, tb)
717 if value.traceback is not tb:
718 raise value.with_traceback(tb)
--> 719 raise value
720 finally:
721 value = None
~/PycharmProjects/myvenv/lib/python3.7/site-packages/keras/utils/data_utils.py in get(self)
608 try:
609 future = self.queue.get(block=True)
--> 610 inputs = future.get(timeout=30)
611 except mp.TimeoutError:
612 idx = future.idx
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/multiprocessing/pool.py in get(self, timeout)
655 return self._value
656 else:
--> 657 raise self._value
658
659 def _set(self, i, obj):
FileNotFoundError: No such file: '/Users/hammadmacho7/PycharmProjects/CondaTest/img-494.png'
whereas if I run the former code line, the error is as follows:
FileNotFoundError Traceback (most recent call last)
/var/folders/q2/2l3cmy9d7ws6npzjdp68gcbm0000gn/T/ipykernel_64715/1877470075.py in
26 nb_y_features = 1, augmentation = aug_with_crop)
27
---> 28 Xtest, ytest = test_generator.getitem(0)
/var/folders/q2/2l3cmy9d7ws6npzjdp68gcbm0000gn/T/ipykernel_64715/4241908483.py in getitem(self, index)
41
42 X_sample, y_sample = self.read_image_mask(self.image_filenames[index * self.batch_size + i],
---> 43 self.mask_names[index * self.batch_size + i])
44
45 # if augmentation is defined, we assume its a train set
/var/folders/q2/2l3cmy9d7ws6npzjdp68gcbm0000gn/T/ipykernel_64715/4241908483.py in read_image_mask(self, image_name, mask_name)
22
23 def read_image_mask(self, image_name, mask_name):
---> 24 return imread(image_name)/255, (imread(mask_name, as_gray=True) > 0).astype(np.int8)
25
26 def getitem(self, index):
~/PycharmProjects/myvenv/lib/python3.7/site-packages/skimage/io/_io.py in imread(fname, as_gray, plugin, **plugin_args)
46
47 with file_or_url_context(fname) as fname:
---> 48 img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
49
50 if not hasattr(img, 'ndim'):
~/PycharmProjects/myvenv/lib/python3.7/site-packages/skimage/io/manage_plugins.py in call_plugin(kind, *args, **kwargs)
205 (plugin, kind))
206
--> 207 return func(*args, **kwargs)
208
209
~/PycharmProjects/myvenv/lib/python3.7/site-packages/skimage/io/_plugins/imageio_plugin.py in imread(*args, **kwargs)
8 @wraps(imageio_imread)
9 def imread(*args, **kwargs):
---> 10 return np.asarray(imageio_imread(*args, **kwargs))
~/PycharmProjects/myvenv/lib/python3.7/site-packages/imageio/init.py in imread(uri, format, **kwargs)
94 )
95
---> 96 return imread_v2(uri, format=format, **kwargs)
97
98
~/PycharmProjects/myvenv/lib/python3.7/site-packages/imageio/v2.py in imread(uri, format, **kwargs)
198 imopen_args["legacy_mode"] = True
199
--> 200 with imopen(uri, "ri", **imopen_args) as file:
201 return file.read(index=0, **kwargs)
202
~/PycharmProjects/myvenv/lib/python3.7/site-packages/imageio/core/imopen.py in imopen(uri, io_mode, plugin, format_hint, legacy_mode, **kwargs)
108 request.format_hint = format_hint
109 else:
--> 110 request = Request(uri, io_mode, format_hint=format_hint)
111
112 source = "" if isinstance(uri, bytes) else uri
~/PycharmProjects/myvenv/lib/python3.7/site-packages/imageio/core/request.py in init(self, uri, mode, format_hint, **kwargs)
246
247 # Parse what was given
--> 248 self._parse_uri(uri)
249
250 # Set extension
~/PycharmProjects/myvenv/lib/python3.7/site-packages/imageio/core/request.py in _parse_uri(self, uri)
386 # Reading: check that the file exists (but is allowed a dir)
387 if not os.path.exists(fn):
--> 388 raise FileNotFoundError("No such file: '%s'" % fn)
389 else:
390 # Writing: check that the directory to write to does exist
FileNotFoundError: No such file: '/Users/hammadmacho7/PycharmProjects/CondaTest/img-94.png'
I really need to solve this issue asap as I have to implement this for a project I am working on, which by the way has a very near deadline.