1
00:00:00,000 --> 00:00:01,000
So guys, finally.

2
00:00:01,000 --> 00:00:05,000
Now let's go ahead and create our end to end web app using Streamlit.

3
00:00:05,000 --> 00:00:10,000
So here in the LSTM folder I will just go ahead and create my another file which is called as app dot

4
00:00:10,000 --> 00:00:11,000
Pi.

5
00:00:11,000 --> 00:00:12,000
Okay.

6
00:00:12,000 --> 00:00:15,000
Now first of all uh this will be a Streamlit app.

7
00:00:15,000 --> 00:00:18,000
So let's go ahead and import all the important libraries.

8
00:00:18,000 --> 00:00:21,000
So this will basically be my important libraries that I need to load.

9
00:00:22,000 --> 00:00:27,000
Uh pickle numpy streamlit and will also be using this load model so that we'll be able to load the H5

10
00:00:27,000 --> 00:00:28,000
file.

11
00:00:28,000 --> 00:00:30,000
And then we'll also be using this pad sequences.

12
00:00:30,000 --> 00:00:31,000
Okay.

13
00:00:31,000 --> 00:00:37,000
Now the first thing is that we will quickly load the LSTM model okay.

14
00:00:37,000 --> 00:00:42,000
And then I will be having model is equal to load underscore model.

15
00:00:42,000 --> 00:00:46,000
And then I will go ahead and use my H5 file name.

16
00:00:46,000 --> 00:00:48,000
It is nothing but next word underscore LSTM.

17
00:00:48,000 --> 00:00:55,000
Okay so here I am going to write next word underscore LSTM dot h five.

18
00:00:55,000 --> 00:00:56,000
Okay.

19
00:00:56,000 --> 00:01:01,000
Then uh, you'll also be able to see that I will load the tokenizer.

20
00:01:01,000 --> 00:01:04,000
Okay tokenizer.

21
00:01:04,000 --> 00:01:05,000
And here I'm going to write with open.

22
00:01:06,000 --> 00:01:09,000
It is nothing but tokenizer.

23
00:01:10,000 --> 00:01:19,000
Uh dot pickle comma lead byte mode as handle okay.

24
00:01:19,000 --> 00:01:28,000
And then I'm going to basically use tokenizer is equal to pickle dot load with respect to our handle.

25
00:01:29,000 --> 00:01:30,000
Okay.

26
00:01:30,000 --> 00:01:32,000
So I'm going to specifically use this.

27
00:01:32,000 --> 00:01:38,000
And here uh now what I will do is that once I have loaded this the same function, I will go ahead and

28
00:01:38,000 --> 00:01:40,000
copy and paste it over here to predict the next word.

29
00:01:40,000 --> 00:01:41,000
Right.

30
00:01:41,000 --> 00:01:43,000
And here how we are basically taking the text to sequence.

31
00:01:43,000 --> 00:01:49,000
Then we are checking the max sequence length and then getting the token list and predicting the board

32
00:01:49,000 --> 00:01:51,000
based on the index that I'm actually getting right.

33
00:01:51,000 --> 00:01:53,000
So this we will be specifically using it okay.

34
00:01:54,000 --> 00:01:56,000
So I'm copying and pasting from the same ipynb file.

35
00:01:57,000 --> 00:01:59,000
Now I will go ahead and write my Streamlit app.

36
00:01:59,000 --> 00:02:08,000
And now let's say I'll go ahead and write SD dot title our next word prediction.

37
00:02:08,000 --> 00:02:14,000
Prediction with LSTM and early stopping.

38
00:02:14,000 --> 00:02:18,000
Okay, now quickly let's do one thing.

39
00:02:18,000 --> 00:02:19,000
Let me just go ahead and write input.

40
00:02:19,000 --> 00:02:25,000
Underscore text is equal to s t dot text underscore input okay.

41
00:02:25,000 --> 00:02:28,000
Test underscore input.

42
00:02:28,000 --> 00:02:35,000
And here we are going to basically tell enter the sequence of word

43
00:02:36,000 --> 00:02:41,000
Sequence of words.

44
00:02:41,000 --> 00:02:41,000
Okay.

45
00:02:42,000 --> 00:02:46,000
And, uh, let me just go ahead and write one of the word over here by default.

46
00:02:46,000 --> 00:02:46,000
Okay.

47
00:02:46,000 --> 00:02:51,000
So it should be something like this to be or not to be.

48
00:02:51,000 --> 00:02:52,000
Okay.

49
00:02:53,000 --> 00:02:57,000
So this will basically be my default value that will be present inside my text input box.

50
00:02:57,000 --> 00:03:01,000
So here I will just go ahead and create my button I'll write SD dot button.

51
00:03:01,000 --> 00:03:09,000
And here I will go ahead and write predict next word okay.

52
00:03:09,000 --> 00:03:10,000
Done.

53
00:03:10,000 --> 00:03:17,000
After this what I am actually going to quickly do is that, uh, I'll say, hey, uh, if this button

54
00:03:17,000 --> 00:03:22,000
is clicked right then first of all, I will do this.

55
00:03:22,000 --> 00:03:23,000
Three important things.

56
00:03:23,000 --> 00:03:24,000
Okay.

57
00:03:24,000 --> 00:03:27,000
So one is get my max equal length plus one.

58
00:03:27,000 --> 00:03:30,000
Retrieve the max equal length from the input model input shape.

59
00:03:30,000 --> 00:03:35,000
Then predict next word where we are passing model tokenizer input text and match sequence length.

60
00:03:35,000 --> 00:03:38,000
And finally I'm just going to predict the output okay.

61
00:03:38,000 --> 00:03:41,000
So finally guys let's go ahead and run this entire project.

62
00:03:41,000 --> 00:03:45,000
So I will just go ahead and open this in my LSTM RNN.

63
00:03:45,000 --> 00:03:49,000
And now let me just go ahead and write Streamlit run App.py.

64
00:03:50,000 --> 00:03:51,000
Okay.

65
00:03:51,000 --> 00:03:53,000
Um, Streamlit.

66
00:03:53,000 --> 00:03:59,000
Okay, so once I execute this, uh, here is my entire Streamlit app.

67
00:03:59,000 --> 00:04:00,000
Okay.

68
00:04:01,000 --> 00:04:07,000
And, uh, it will take some time to load all the models and all, so I think it should be loading the

69
00:04:07,000 --> 00:04:07,000
models over here.

70
00:04:07,000 --> 00:04:11,000
So here you can see TF enable on this, this this this.

71
00:04:11,000 --> 00:04:12,000
Yes.

72
00:04:12,000 --> 00:04:12,000
Perfect.

73
00:04:13,000 --> 00:04:14,000
Okay.

74
00:04:14,000 --> 00:04:17,000
Uh, again it depends on your system how fast you're able to load it.

75
00:04:17,000 --> 00:04:19,000
How big are the specific model is?

76
00:04:19,000 --> 00:04:23,000
Because in the initial stage when you are loading it, it obviously needs some time, right.

77
00:04:23,000 --> 00:04:26,000
And here you're getting also some warnings.

78
00:04:26,000 --> 00:04:30,000
The name TF dot get default bar graph is deprecated.

79
00:04:30,000 --> 00:04:31,000
It's okay.

80
00:04:31,000 --> 00:04:34,000
So here uh is my entire application.

81
00:04:34,000 --> 00:04:37,000
Next word prediction with LSTM early stopping to be or not to be?

82
00:04:37,000 --> 00:04:38,000
Predict the next word.

83
00:04:39,000 --> 00:04:44,000
And I should be able to get something like crack over here To be or not to be is like crack.

84
00:04:45,000 --> 00:04:46,000
Uh, to be or not to crack.

85
00:04:46,000 --> 00:04:47,000
Okay.

86
00:04:47,000 --> 00:04:48,000
This looks good.

87
00:04:48,000 --> 00:04:55,000
Uh, let us try some more words for our page, you know, so I'll go over here, I'll open my hamlet

88
00:04:55,000 --> 00:05:00,000
text, or I'll say Bon video meat, something like this.

89
00:05:02,000 --> 00:05:04,000
And let's predict the next word.

90
00:05:05,000 --> 00:05:06,000
So.

91
00:05:06,000 --> 00:05:06,000
Well.

92
00:05:06,000 --> 00:05:06,000
Good night.

93
00:05:06,000 --> 00:05:10,000
If you do meet two, it has basically come as two.

94
00:05:10,000 --> 00:05:15,000
But again, I think, uh, I will just go ahead and use one more word.

95
00:05:15,000 --> 00:05:20,000
But again, if the accuracy keeps on increasing, I think we should be able to get the, uh, ma and

96
00:05:20,000 --> 00:05:22,000
lingman to do the performed test.

97
00:05:22,000 --> 00:05:25,000
Okay, so this also is a good meaning.

98
00:05:25,000 --> 00:05:26,000
Uh, if you probably go ahead and see.

99
00:05:26,000 --> 00:05:27,000
So.

100
00:05:27,000 --> 00:05:28,000
Welcome.

101
00:05:28,000 --> 00:05:28,000
Good.

102
00:05:28,000 --> 00:05:29,000
Something like this.

103
00:05:29,000 --> 00:05:30,000
Okay.

104
00:05:30,000 --> 00:05:33,000
I will just go ahead and predict one more thing.

105
00:05:34,000 --> 00:05:37,000
Um, friends, this is also nice, right?

106
00:05:37,000 --> 00:05:37,000
Welcome.

107
00:05:37,000 --> 00:05:38,000
Uh, bar.

108
00:05:38,000 --> 00:05:39,000
Welcome, Horatio.

109
00:05:39,000 --> 00:05:39,000
Welcome.

110
00:05:39,000 --> 00:05:40,000
Good friends.

111
00:05:41,000 --> 00:05:44,000
So I hope you were able to understand this entire project, guys.

112
00:05:44,000 --> 00:05:45,000
And, um.

113
00:05:45,000 --> 00:05:46,000
Yeah, this was it for my side.

114
00:05:46,000 --> 00:05:48,000
Uh, go ahead and try it out.

115
00:05:48,000 --> 00:05:52,000
And again, if you want more, better accuracy, keep on training for another 50 epochs.

116
00:05:53,000 --> 00:05:55,000
You will definitely be able to get a good result out there.

117
00:05:55,000 --> 00:05:56,000
Right?

118
00:05:56,000 --> 00:05:57,000
So yes, this was it for my side.

119
00:05:57,000 --> 00:05:59,000
I will see you all in the next video.

120
00:05:59,000 --> 00:05:59,000
Thank you.

