Mar-26-2022, 02:55 PM
I upload the data in BatchDataset using the image_dataset_from_directory method
seed = 64 images = tf.keras.utils.image_dataset_from_directory( '/content/drive/MyDrive/DATA_PYTHON/Recognize_Alphabet/Recognize_Alphabet', validation_split=0.2, image_size=(34, 34), color_mode='rgb', interpolation='nearest', subset='training', seed=seed)I want to invert the colors for all the images that I uploaded. To do this, I try to write a method:
def invertColor(im, b): sess2 = tf2.Session() im = sess2.run(im) imI = PIL.ImageOps.invert(im) imIN = np.asarray(imI) imINC = cv2.cvtColor(imIN, cv2.COLOR_BGR2RGB) bI = Image.fromarray(imINC, 'RGB') return bIWhen I call the map with this invertColor method
images2 = images.map(invertColor)I'm getting this errors:
Error:InvalidArgumentError: in user code:
File "<ipython-input-19-1f1e09851e25>", line 5, in invertColor *
sess2.run(im)
InvalidArgumentError: Graph execution error:
Detected at node 'args_0' defined at (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
How can I get the value of im element in the invertColor method? (Or how to invert colors in the BatchDataset?)