Image_Captioning_Bot

why is the error occurring and also the no file is getting saved for the model weights
https://drive.google.com/file/d/1hx3ljrWoWRLuZTv6KFhysM8e9uObaH3u/view?usp=sharing

hey @rajukumarbhui ,
Kindly provide access to view this file to whomsoever have this link , i am unable to view your code.

Happy Learning. :slight_smile:

kindly visit this link i have change the access rights to anyone .please suggest me the errors , https://drive.google.com/file/d/1hx3ljrWoWRLuZTv6KFhysM8e9uObaH3u/view?usp=sharing

hey @rajukumarbhui ,
did you called the train function before loading your model. Your code shows you haven’t. Kindly have a look at it.

Just a suggestion , don’t run a for loop like this to iterate over epochs , you can directly state the number of epochs you want to run for in its epochs parameter.
and to save the model , Kindly have a look at ModelCheckpoint Callback in keras.callbacks . It will work the same as you are doing now, but the code will more clean ,clear and understandable.

i have called the train function and done almost according to the tutorial still facing the error https://drive.google.com/file/d/1hx3ljrWoWRLuZTv6KFhysM8e9uObaH3u/view?usp=sharing

hey @rajukumarbhui,
Your train variable looks like just having filenames without extension ok.
so consider key = “2513260012_03d33305cf” ( first value in train )
then you created train descriptions with different keys like key.
so there will be something train_descriptions[ key ]. Correct.
now you created encoding_train dictionary the same way as train descriptions , there will be some value as encoding_train[ key ] / encoding_train[ " 2513260012_03d33305cf" ] ( same thing ).
Till Now your were working great , awesome.

Then in data_generator you used

photo = encoding_train[key+".jpg"]

here you want to access encoding_train with key+extension , and as you can above you haven’t initialized it with extensions. That is the point where are getting your current KeyError.

Just correct it and try your code again.
I hope this would help you.

Happy Learning :slightly_smiling_face: .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.