FoodNet icon indicating copy to clipboard operation
FoodNet copied to clipboard

Error in the build_model

Open Likhith22 opened this issue 1 year ago • 10 comments

While running build_model after set up the datasets I got an error

Epoch 1/30

ValueError Traceback (most recent call last) Cell In[97], line 3 1 print("Shape of training data:", no_category_train.map) 2 print("Shape of validation data:", no_category_val.map) ----> 3 flat_efficientnet.train_model( 4 x=no_category_train, 5 validation_data=no_category_val, 6 epochs=30, 7 verbose=2, 8 )

Cell In[93], line 282, in BaseModel.train_model(self, **kwargs) 280 def train_model(self, **kwargs): 281 assert self.model is not None, "No model found." --> 282 return self.model.fit(**kwargs, callbacks=self.get_callbacks())

File ~\anaconda3\lib\site-packages\keras\src\utils\traceback_utils.py:123, in filter_traceback..error_handler(*args, **kwargs) 120 filtered_tb = _process_traceback_frames(e.traceback) 121 # To get the full stack trace, call: 122 # keras.config.disable_traceback_filtering() --> 123 raise e.with_traceback(filtered_tb) from None 124 finally: 125 del filtered_tb

File ~\anaconda3\lib\site-packages\keras\src\losses\loss.py:87, in squeeze_or_expand_to_same_rank(x1, x2, expand_rank_1) 85 def squeeze_or_expand_to_same_rank(x1, x2, expand_rank_1=True): 86 """Squeeze/expand last dim if ranks differ from expected by exactly 1.""" ---> 87 x1_rank = len(x1.shape) 88 x2_rank = len(x2.shape) 89 if x1_rank == x2_rank:

ValueError: Cannot take the length of shape with unknown rank.

Likhith22 avatar Mar 28 '24 05:03 Likhith22

Hi, can you provide more details like the dataset setup in the folder? Just checking did you follow the exact dependencies version provided in the repository?

Cheng-K avatar Mar 30 '24 04:03 Cheng-K

yeah sure, This is the food dataset folder inside the FoodNet folder food dataset

This is the final-dataset folder inside the food dataset folder final-dataset

This is the food-101 folder inside the food dataset folder food-101

This is the nutrition5k folder inside the food dataset folder nutrition5k

This is the recipes5k folder inside the food dataset folder recipes5k

This is the USDA-FNDDS folder inside the food dataset folder USDA-FNDDS

Likhith22 avatar Mar 30 '24 17:03 Likhith22

I have a doubt regarding creation of generic folder, Whether I should create a generic folder inside a final-dataset and what it will store.

Likhith22 avatar Apr 01 '24 07:04 Likhith22

i can‘t find the dataset Recipes5k in the wedsite "http://www.ub.edu/cvub/recipes5k/" ,it seems that no longer exist,could you please help me? thank you very much!

fenglinzhu123 avatar Jul 10 '24 09:07 fenglinzhu123

i can‘t find the dataset Recipes5k in the wedsite "http://www.ub.edu/cvub/recipes5k/" ,it seems that no longer exist,could you please help me? thank you very much!

Hi I am also looking for it. Have you find a copy of it ?

rdaking avatar Sep 10 '24 00:09 rdaking

i can‘t find the dataset Recipes5k in the wedsite "http://www.ub.edu/cvub/recipes5k/" ,it seems that no longer exist,could you please help me? thank you very much!

Hi I am also looking for it. Have you find a copy of it ?

Hey @rdaking @fenglinzhu123, hope I am not too late to the conversation. I found the exact copy in kaggle https://www.kaggle.com/datasets/terry9a9/recipes5k

Cheng-K avatar Oct 01 '24 14:10 Cheng-K

This is awesome you're more than welcome

I'll get it and run the code against it again.

Thanks to you

rdaking avatar Oct 01 '24 16:10 rdaking

This is awesome you're more than welcome

I'll get it and run the code against it again.

Thanks to you

Can you please give me the full working code

mohanaprakash-23 avatar Oct 21 '24 19:10 mohanaprakash-23

I would like to ask if the image in the nutrition5k part has more than 180 g. Can I only download the image part and not the video part?

Sunstreamy avatar Feb 04 '25 13:02 Sunstreamy

While running build_model after set up the datasets I got an error

Epoch 1/30

ValueError Traceback (most recent call last) Cell In[97], line 3 1 print("Shape of training data:", no_category_train.map) 2 print("Shape of validation data:", no_category_val.map) ----> 3 flat_efficientnet.train_model( 4 x=no_category_train, 5 validation_data=no_category_val, 6 epochs=30, 7 verbose=2, 8 )

Cell In[93], line 282, in BaseModel.train_model(self, **kwargs) 280 def train_model(self, **kwargs): 281 assert self.model is not None, "No model found." --> 282 return self.model.fit(**kwargs, callbacks=self.get_callbacks())

File ~\anaconda3\lib\site-packages\keras\src\utils\traceback_utils.py:123, in filter_traceback..error_handler(*args, **kwargs) 120 filtered_tb = _process_traceback_frames(e.traceback) 121 # To get the full stack trace, call: 122 # keras.config.disable_traceback_filtering() --> 123 raise e.with_traceback(filtered_tb) from None 124 finally: 125 del filtered_tb

File ~\anaconda3\lib\site-packages\keras\src\losses\loss.py:87, in squeeze_or_expand_to_same_rank(x1, x2, expand_rank_1) 85 def squeeze_or_expand_to_same_rank(x1, x2, expand_rank_1=True): 86 """Squeeze/expand last dim if ranks differ from expected by exactly 1.""" ---> 87 x1_rank = len(x1.shape) 88 x2_rank = len(x2.shape) 89 if x1_rank == x2_rank:

ValueError: Cannot take the length of shape with unknown rank.

Hi, I got the same error when I train the model, did you fix this error? @Likhith22

Lottie-641 avatar Mar 07 '25 17:03 Lottie-641