Replies: 1 comment 2 replies
-
Hello,
Make sure you include the color channels in your shape. It is 3 (for RGB)
if the images are colored or 1 if the images are in greyscale.
On Tue, Jul 19, 2022 at 4:09 PM reshma93s ***@***.***> wrote:
I am getting an error where the data is batched and pre-processed.
Map preprocessing function to training data (and paralellize)
train_data = train_data.map(map_func=preprocess_img,
num_parallel_calls=tf.data.AUTOTUNE)
Shuffle train_data and turn it into batches and prefetch it (load it
faster)
train_data =
train_data.shuffle(buffer_size=1000).batch(batch_size=32).prefetch(buffer_size=tf.data.AUTOTUNE)
Error:-
------------------------------
ValueError Traceback (most recent call last)
<https://localhost:8080/#> in ()
1 # Map preprocessing function to training data (and paralellize)
----> 2 train_data = train_data.map(map_func=preprocess_img,
num_parallel_calls=tf.data.AUTOTUNE)
3 # Shuffle train_data and turn it into batches and prefetch it (load it
faster)
4 train_data =
train_data.shuffle(buffer_size=1000).batch(batch_size=32).prefetch(buffer_size=tf.data.AUTOTUNE)
10 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py
<https://localhost:8080/#> in wrapper(*args, **kwargs)
690 except Exception as e: # pylint:disable=broad-except
691 if hasattr(e, 'ag_error_metadata'):
--> 692 raise e.ag_error_metadata.to_exception(e)
693 else:
694 raise
ValueError: in user code:
File "<ipython-input-20-16eda5b2fbee>", line 6, in preprocess_img *
image = tf.image.resize(image,[img_shape,img_shape])
ValueError: 'images' must have either 3 or 4 dimensions.
—
Reply to this email directly, view it on GitHub
<#414>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF2IW5WT6YJQZ2IHYDSPRG3VU2AU3ANCNFSM537PNPNA>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Warmest Regards,
Shreyas Mocherla
Student of Grade 12, Indus International School Hyderabad
Visit my page at shreyasm.com
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am getting an error where the data is batched and pre-processed.
Map preprocessing function to training data (and paralellize)
train_data = train_data.map(map_func=preprocess_img, num_parallel_calls=tf.data.AUTOTUNE)
Shuffle train_data and turn it into batches and prefetch it (load it faster)
train_data = train_data.shuffle(buffer_size=1000).batch(batch_size=32).prefetch(buffer_size=tf.data.AUTOTUNE)
Error:-
ValueError Traceback (most recent call last)
in ()
1 # Map preprocessing function to training data (and paralellize)
----> 2 train_data = train_data.map(map_func=preprocess_img, num_parallel_calls=tf.data.AUTOTUNE)
3 # Shuffle train_data and turn it into batches and prefetch it (load it faster)
4 train_data = train_data.shuffle(buffer_size=1000).batch(batch_size=32).prefetch(buffer_size=tf.data.AUTOTUNE)
10 frames
/usr/local/lib/python3.7/dist-packages/tensorflow/python/autograph/impl/api.py in wrapper(*args, **kwargs)
690 except Exception as e: # pylint:disable=broad-except
691 if hasattr(e, 'ag_error_metadata'):
--> 692 raise e.ag_error_metadata.to_exception(e)
693 else:
694 raise
ValueError: in user code:
Beta Was this translation helpful? Give feedback.
All reactions