So guys, finally.
Now let's go ahead and create our end to end web app using Streamlit.
So here in the LSTM folder I will just go ahead and create my another file which is called as app dot
Pi.
Okay.
Now first of all uh this will be a Streamlit app.
So let's go ahead and import all the important libraries.
So this will basically be my important libraries that I need to load.
Uh pickle numpy streamlit and will also be using this load model so that we'll be able to load the H5
file.
And then we'll also be using this pad sequences.
Okay.
Now the first thing is that we will quickly load the LSTM model okay.
And then I will be having model is equal to load underscore model.
And then I will go ahead and use my H5 file name.
It is nothing but next word underscore LSTM.
Okay so here I am going to write next word underscore LSTM dot h five.
Okay.
Then uh, you'll also be able to see that I will load the tokenizer.
Okay tokenizer.
And here I'm going to write with open.
It is nothing but tokenizer.
Uh dot pickle comma lead byte mode as handle okay.
And then I'm going to basically use tokenizer is equal to pickle dot load with respect to our handle.
Okay.
So I'm going to specifically use this.
And here uh now what I will do is that once I have loaded this the same function, I will go ahead and
copy and paste it over here to predict the next word.
Right.
And here how we are basically taking the text to sequence.
Then we are checking the max sequence length and then getting the token list and predicting the board
based on the index that I'm actually getting right.
So this we will be specifically using it okay.
So I'm copying and pasting from the same ipynb file.
Now I will go ahead and write my Streamlit app.
And now let's say I'll go ahead and write SD dot title our next word prediction.
Prediction with LSTM and early stopping.
Okay, now quickly let's do one thing.
Let me just go ahead and write input.
Underscore text is equal to s t dot text underscore input okay.
Test underscore input.
And here we are going to basically tell enter the sequence of word
Sequence of words.
Okay.
And, uh, let me just go ahead and write one of the word over here by default.
Okay.
So it should be something like this to be or not to be.
Okay.
So this will basically be my default value that will be present inside my text input box.
So here I will just go ahead and create my button I'll write SD dot button.
And here I will go ahead and write predict next word okay.
Done.
After this what I am actually going to quickly do is that, uh, I'll say, hey, uh, if this button
is clicked right then first of all, I will do this.
Three important things.
Okay.
So one is get my max equal length plus one.
Retrieve the max equal length from the input model input shape.
Then predict next word where we are passing model tokenizer input text and match sequence length.
And finally I'm just going to predict the output okay.
So finally guys let's go ahead and run this entire project.
So I will just go ahead and open this in my LSTM RNN.
And now let me just go ahead and write Streamlit run App.py.
Okay.
Um, Streamlit.
Okay, so once I execute this, uh, here is my entire Streamlit app.
Okay.
And, uh, it will take some time to load all the models and all, so I think it should be loading the
models over here.
So here you can see TF enable on this, this this this.
Yes.
Perfect.
Okay.
Uh, again it depends on your system how fast you're able to load it.
How big are the specific model is?
Because in the initial stage when you are loading it, it obviously needs some time, right.
And here you're getting also some warnings.
The name TF dot get default bar graph is deprecated.
It's okay.
So here uh is my entire application.
Next word prediction with LSTM early stopping to be or not to be?
Predict the next word.
And I should be able to get something like crack over here To be or not to be is like crack.
Uh, to be or not to crack.
Okay.
This looks good.
Uh, let us try some more words for our page, you know, so I'll go over here, I'll open my hamlet
text, or I'll say Bon video meat, something like this.
And let's predict the next word.
So.
Well.
Good night.
If you do meet two, it has basically come as two.
But again, I think, uh, I will just go ahead and use one more word.
But again, if the accuracy keeps on increasing, I think we should be able to get the, uh, ma and
lingman to do the performed test.
Okay, so this also is a good meaning.
Uh, if you probably go ahead and see.
So.
Welcome.
Good.
Something like this.
Okay.
I will just go ahead and predict one more thing.
Um, friends, this is also nice, right?
Welcome.
Uh, bar.
Welcome, Horatio.
Welcome.
Good friends.
So I hope you were able to understand this entire project, guys.
And, um.
Yeah, this was it for my side.
Uh, go ahead and try it out.
And again, if you want more, better accuracy, keep on training for another 50 epochs.
You will definitely be able to get a good result out there.
Right?
So yes, this was it for my side.
I will see you all in the next video.
Thank you.