-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running segformer error : ValueError: Attempt to convert a value (<generator object preprocessing at 0x7f59f0168f40>) with an unsupported type (<class 'generator'>) to a Tensor. #2054
Comments
Hi @Masumekeshavarzi - Can you share code and more relevant details for reproducing the bug ? |
Hi mehtamansi29 . Thanks for your reply. I am trying to use the segformer model using mit_b3 backbone. I defined the model based on the documentation as below:
While fitting model I got this error : history=model.fit(processed_train_generator,steps_per_epoch=step_train,epochs=epoch_num, Then I tried to convert the dataset from datagenerator to tf.dataset with this function :
when I print the tensors :
I got this : processed_train_generator <_FlatMapDataset element_spec=(TensorSpec(shape=(8, 768, 768, 3), dtype=tf.float32, name=None), TensorSpec(shape=(8, 768, 768, 12), dtype=tf.float32, name=None))> At this stage running model.fit will give this warning and the process get stock like without being killed or anything. Expected: ['keras_tensor_1'] |
Hi @Masumekeshavarzi - Could you please provide a dummy dataset to reproduce this error ? |
Hi @sonali-kumari1 , please find a small part of the dataset I used here: https://drive.google.com/drive/folders/1LahNRVPH4PWI0OfmmitS297qKm7QXWey?usp=sharing |
Hi @mehtamansi29 . Any solution for me? |
Hi @Masumekeshavarzi - Thanks for dataset and sample code. We'll look into it more and update you on that. |
Hi mehtamansi29, thanks for your consideration. I noticed that with the low number of images, the mode fitting starts (using defined preprocess function), while with the main dataset, which is 5460 training images and 1554 validation images, it stocks and takes 4 hours for every epoch while the val_loss is nan !!! |
That error is happening because the function is returning a "zip of generators" instead of one generator maybe. Can you please provide a minimal repro colab?
And then, you can probably pass the above generator directly to model.fit()? |
Thanks for your reply @divyashreepathihalli . Actually no difference between ```
img_msk_generated=zip(img_data_gen,msk_data_gen)
|
Dear @divyashreepathihalli this is a colab file |
Describe the bug
To Reproduce
Expected behavior
The text was updated successfully, but these errors were encountered: