1
00:00:00,080 --> 00:00:00,440
All right.

2
00:00:00,440 --> 00:00:01,920
So first of all I'm going to take my mouse.

3
00:00:01,920 --> 00:00:03,400
I'm going to hover around here.

4
00:00:03,440 --> 00:00:05,960
I'm going to press the plus code button.

5
00:00:06,240 --> 00:00:07,480
It's very like cursor.

6
00:00:07,720 --> 00:00:13,520
Uh and I'm going to go here and type two plus two and hold down shift and press enter.

7
00:00:13,760 --> 00:00:21,320
And we just used a Tesla T4 machine, uh, on the cloud in order to do this important operation.

8
00:00:21,520 --> 00:00:24,680
Uh, and, you know, we can we can do bananas.

9
00:00:25,120 --> 00:00:27,680
Uh, and uh, there we go.

10
00:00:27,720 --> 00:00:29,160
We get we get bananas.

11
00:00:29,320 --> 00:00:35,280
Um, and, um, yes, you you can imagine all the other great things we could do.

12
00:00:35,680 --> 00:00:42,800
Uh, a lot of stuff comes installed automatically on radios that you don't even need to pip install.

13
00:00:42,800 --> 00:00:46,240
So I can do like import gradio as GR.

14
00:00:46,280 --> 00:00:47,680
And I think that will just run.

15
00:00:48,120 --> 00:00:49,520
Doesn't need anything installed.

16
00:00:49,520 --> 00:00:52,040
Gradio just comes on the box.

17
00:00:52,040 --> 00:00:53,720
So it's as slow as it is on my machine.

18
00:00:53,720 --> 00:00:54,320
Look at that.

19
00:00:54,640 --> 00:00:55,960
Uh, you get used to this.

20
00:00:56,000 --> 00:00:57,200
Obviously that's the stop button.

21
00:00:57,200 --> 00:01:00,110
You can press the stop at any point if it's taking too long.

22
00:01:00,110 --> 00:01:01,030
But it did finish.

23
00:01:01,430 --> 00:01:08,030
Um, if you need to pip install something you can't just do like pip install pip install requests or

24
00:01:08,030 --> 00:01:08,550
something.

25
00:01:08,670 --> 00:01:13,830
Uh, you would have to put an exclamation mark in front of it, which is a way of saying don't run this

26
00:01:13,830 --> 00:01:17,350
as Python, run this as an underlying shell command.

27
00:01:17,510 --> 00:01:18,630
That's what that would do.

28
00:01:18,630 --> 00:01:21,310
But for this notebook we don't need to do any Pip installs.

29
00:01:21,310 --> 00:01:23,310
Everything is good to go.

30
00:01:23,830 --> 00:01:26,390
The first thing we're going to do is a little bit of code here.

31
00:01:26,790 --> 00:01:34,430
Uh, to check the GPU of this code, of this box, whatever this is running on out in the cloud by calling

32
00:01:34,430 --> 00:01:41,630
this this shell command Nvidia SMI to get the GPU info and find out what it is and print it if it is

33
00:01:41,630 --> 00:01:42,790
a Tesla T4.

34
00:01:42,830 --> 00:01:44,150
Let's run this code.

35
00:01:44,390 --> 00:01:44,990
Bam!

36
00:01:45,150 --> 00:01:46,270
Here's the results.

37
00:01:46,270 --> 00:01:49,070
It is indeed an Nvidia chip.

38
00:01:49,230 --> 00:01:50,110
And there we go.

39
00:01:50,110 --> 00:01:52,110
It is a Tesla T4.

40
00:01:52,150 --> 00:01:53,150
Good to know.

41
00:01:53,430 --> 00:01:57,510
And it has 15MB on it.

42
00:01:57,630 --> 00:02:02,590
And that makes sense because we can see just over here it does indeed, according to Colab, have that

43
00:02:02,590 --> 00:02:03,310
as well.

44
00:02:03,310 --> 00:02:07,350
So the code that's running is giving us a consistent story.

45
00:02:07,350 --> 00:02:08,230
That's good to see.

46
00:02:08,270 --> 00:02:11,870
Okay, next up comes the most important thing we're doing today.

47
00:02:12,190 --> 00:02:13,670
Pay attention please.

48
00:02:13,710 --> 00:02:15,630
There's a fiddly thing to do now.

49
00:02:15,750 --> 00:02:20,310
One fiddly thing one time only and then fiddly ness is over.

50
00:02:20,630 --> 00:02:27,790
Okay, we need to connect this colab to our hugging face account, and in fact, we're connecting any

51
00:02:27,790 --> 00:02:33,870
colab when we're logged in by using a feature that's secrets that are built into colab.

52
00:02:34,150 --> 00:02:36,870
And this is the alternative to the EMV file.

53
00:02:36,870 --> 00:02:39,830
You don't have a dot env file on Colab because we don't.

54
00:02:39,910 --> 00:02:42,590
It's not on our file system, it's out in the cloud.

55
00:02:42,790 --> 00:02:44,230
Here's how it works.

56
00:02:44,230 --> 00:02:49,910
First of all, you need to have got yourself a hugging face account, which you did in the last video

57
00:02:49,910 --> 00:02:50,750
or two videos ago.

58
00:02:50,750 --> 00:02:51,830
So you're good there.

59
00:02:51,870 --> 00:02:52,550
Thank you.

60
00:02:52,710 --> 00:02:54,750
You you you listen to me.

61
00:02:54,750 --> 00:02:56,420
So at this point, please.

62
00:02:56,420 --> 00:02:59,300
Let's go to your hugging face account.

63
00:02:59,300 --> 00:02:59,460
Here.

64
00:02:59,460 --> 00:03:01,900
I have mine open, conveniently hugging face.

65
00:03:02,100 --> 00:03:08,940
So this is me signed in, and, uh, you go to your avatar, you go to your profile.

66
00:03:08,940 --> 00:03:10,820
That is my hugging face profile.

67
00:03:10,860 --> 00:03:13,060
And I have two notifications.

68
00:03:13,060 --> 00:03:13,820
I don't know what they are.

69
00:03:14,020 --> 00:03:18,460
Uh, here are his his, my two apps and some fun things from another course.

70
00:03:18,900 --> 00:03:25,340
Uh, and, uh, then you come along here and you go to settings.

71
00:03:25,620 --> 00:03:31,660
So you're looking at your avatar page, you press settings and you go to API to access tokens.

72
00:03:31,700 --> 00:03:32,580
Access tokens.

73
00:03:32,580 --> 00:03:34,540
This page here, look at this.

74
00:03:34,820 --> 00:03:36,980
Now here is the thing.

75
00:03:37,060 --> 00:03:37,740
Here is the thing.

76
00:03:37,740 --> 00:03:38,420
Listen up.

77
00:03:38,700 --> 00:03:40,700
You press create new token.

78
00:03:40,940 --> 00:03:42,180
Here comes the new token.

79
00:03:42,180 --> 00:03:43,980
You see this page for the new token.

80
00:03:44,020 --> 00:03:47,060
The next thing you do is you find this word right.

81
00:03:47,060 --> 00:03:50,420
You need to press that word right and give it a token name.

82
00:03:50,420 --> 00:03:51,740
Give it whatever token name you like.

83
00:03:51,740 --> 00:03:53,900
This can be, you know, my my favorite token.

84
00:03:53,900 --> 00:03:56,060
And then you press Create token.

85
00:03:56,100 --> 00:04:00,940
Now the reason you need to write permissions is first of all that gives you access to download models

86
00:04:00,940 --> 00:04:04,940
from from any repo which you'll need when we download open source models.

87
00:04:04,940 --> 00:04:08,820
But also we are going to be writing our own models at future weeks.

88
00:04:08,860 --> 00:04:11,500
And if you don't have this permission, it will cause lots of troubles later.

89
00:04:11,500 --> 00:04:13,100
So do have write permissions.

90
00:04:13,340 --> 00:04:17,020
Give it a name, create the token and copy it into your clipboard.

91
00:04:17,020 --> 00:04:21,660
It should start h underscore and that should now be in your clipboard.

92
00:04:21,660 --> 00:04:24,300
And now we go back to Colab okay.

93
00:04:24,340 --> 00:04:30,540
And in Colab you now go to the left here to this little key, and you press the key and it opens up

94
00:04:30,540 --> 00:04:38,060
this thing that says secrets and secrets are they are just like the dot env file.

95
00:04:38,060 --> 00:04:44,220
They have a name and a value, just like the dot env file has something equals something.

96
00:04:44,460 --> 00:04:49,060
And the name for hugging face is underscore token.

97
00:04:49,220 --> 00:04:56,330
And in that value cell you paste the the lowercase HF underscore and that key.

98
00:04:56,450 --> 00:05:02,410
And you put in exactly as it is with no spaces and no nothing random on the beginning or end, just

99
00:05:02,410 --> 00:05:07,210
as it should be, so that you have that in there and you make sure it's switched on here for notebook

100
00:05:07,290 --> 00:05:12,570
access, which means that this notebook here will have access to that secret.

101
00:05:12,730 --> 00:05:15,130
And once you've done that, you're golden.

102
00:05:15,130 --> 00:05:16,890
You've done the fiddly part.

103
00:05:16,930 --> 00:05:22,010
You can now access this hugging face token from your code, and it even tells you right there that it's

104
00:05:22,010 --> 00:05:29,050
super simple over here to have access to any of these keys with code that looks a bit like that, but

105
00:05:29,090 --> 00:05:34,210
instead of secret name, you would put this word here, that word would go there, and then you'd be

106
00:05:34,210 --> 00:05:36,730
able to access this value.

107
00:05:36,890 --> 00:05:40,090
It's just a way to have secrets stored separately.

108
00:05:40,090 --> 00:05:43,850
And these secrets here are associated with your Google account.

109
00:05:43,850 --> 00:05:47,610
If you share this with someone else, they won't get access to your secrets.

110
00:05:47,610 --> 00:05:50,170
The secrets, of course, are secret to you.

111
00:05:50,170 --> 00:05:54,890
And as an added benefit, anytime you're logged in, you'll have access to all of these secrets, which

112
00:05:54,890 --> 00:05:56,410
makes it super convenient.

113
00:05:56,410 --> 00:06:02,290
It's like a EMV file that's everywhere on Google Colab for you and only for you when you're logged in.

114
00:06:02,930 --> 00:06:04,370
So that's the fiddly part.

115
00:06:04,410 --> 00:06:05,410
Done, sorted.

116
00:06:05,410 --> 00:06:06,490
You've got it set up.

117
00:06:06,530 --> 00:06:07,330
Brilliant.

118
00:06:07,730 --> 00:06:08,650
Let's go on.

119
00:06:08,850 --> 00:06:09,490
Okay.

120
00:06:10,050 --> 00:06:11,010
Game time.

121
00:06:11,250 --> 00:06:12,530
You've filled in your secrets.

122
00:06:12,530 --> 00:06:14,130
You've connected to a T4.

123
00:06:14,370 --> 00:06:16,490
You're looking all good there.

124
00:06:16,690 --> 00:06:18,010
Scroll down.

125
00:06:18,170 --> 00:06:23,650
So first of all, this is exactly the code that you may remember you saw just here.

126
00:06:23,850 --> 00:06:28,650
It's the code which is going to allow us to access our HRF token.

127
00:06:28,650 --> 00:06:33,890
And it's going into a something called HRF token, a variable called that.

128
00:06:34,050 --> 00:06:37,530
And that's coming from Google Colab importing user data.

129
00:06:37,530 --> 00:06:40,050
So user data is basically the secrets on the left.

130
00:06:40,050 --> 00:06:42,130
We're getting HRF token and there it is.

131
00:06:42,170 --> 00:06:45,770
And then we're calling something called login with HRF token.

132
00:06:45,770 --> 00:06:46,890
And what is that?

133
00:06:46,890 --> 00:06:52,040
That that is a function from a package called Huggingface hub.

134
00:06:52,200 --> 00:06:55,280
And this is the first of those libraries I told you about.

135
00:06:55,280 --> 00:07:00,360
This is the Hugging face library that's related to connecting to the Hugging Face Hub.

136
00:07:00,400 --> 00:07:01,320
Okay, let's do it.

137
00:07:01,320 --> 00:07:02,240
Let's run this.

138
00:07:02,440 --> 00:07:06,600
And if all is well, if you've done the key properly, if you've copied and pasted, if it has the right

139
00:07:06,600 --> 00:07:09,680
permissions and everything, you'll have a green tick there.

140
00:07:09,880 --> 00:07:12,760
And this running on the cloud is now connected.

141
00:07:12,760 --> 00:07:14,800
It's logged in to Huggingface.

142
00:07:15,120 --> 00:07:21,400
So what I'm now going to do is run a piece of code that I'm not going to explain how it works, because

143
00:07:21,400 --> 00:07:23,000
we'll be dealing with that another time.

144
00:07:23,000 --> 00:07:25,000
It's using something called pipelines.

145
00:07:25,280 --> 00:07:27,640
And we are going to be first.

146
00:07:27,680 --> 00:07:31,000
We are going to be, uh, let's see what order do I want to do these in?

147
00:07:31,040 --> 00:07:31,520
Yeah okay.

148
00:07:31,520 --> 00:07:32,080
Okay.

149
00:07:32,120 --> 00:07:37,640
So first of all, we are going to be using, uh, something that isn't going to be using a model, a

150
00:07:37,640 --> 00:07:39,480
model from the Hugging Face library.

151
00:07:39,560 --> 00:07:41,640
But it is not a transformer.

152
00:07:41,640 --> 00:07:43,240
It is actually a different kind of model.

153
00:07:43,240 --> 00:07:46,240
It is a diffusion model that you may have heard of.

154
00:07:46,280 --> 00:07:49,600
It is a kind of model that's good at generating images.

155
00:07:49,600 --> 00:07:56,240
And we're making one from a company called stability, uh, which is, uh, the, uh, the, the stability

156
00:07:56,280 --> 00:07:59,640
diffusion model, and it's called Excel Turbo.

157
00:07:59,880 --> 00:08:08,640
And we are going to ask it to generate a class of students learning AI engineering in a vibrant pop

158
00:08:08,680 --> 00:08:09,880
art style.

159
00:08:10,040 --> 00:08:11,520
So that is our prompt.

160
00:08:11,760 --> 00:08:15,040
We are using something called pipelines that we will tackle.

161
00:08:15,040 --> 00:08:21,720
We'll actually explain this tomorrow, but I'm doing it because this is now hitting our our T4.

162
00:08:22,040 --> 00:08:25,040
So we should start to see work happening down here.

163
00:08:25,040 --> 00:08:30,080
It says it's been executing for 22 seconds on the T4 and things are happening.

164
00:08:30,080 --> 00:08:30,280
Whoa.

165
00:08:30,320 --> 00:08:30,880
Look at all this.

166
00:08:30,880 --> 00:08:32,400
Lots of status things.

167
00:08:32,400 --> 00:08:40,320
So a lot of the time that you spend on Colab is actually spent downloading stuff, because the downside

168
00:08:40,320 --> 00:08:46,400
of it being a completely clean box every time is that it doesn't cache any files you're downloading

169
00:08:46,400 --> 00:08:49,480
things from the Hugging Face Hub every single time.

170
00:08:49,640 --> 00:08:51,720
So all of this is downloading.

171
00:08:51,720 --> 00:08:57,000
You can see here it says that's almost a 1.4GB of data coming there.

172
00:08:57,240 --> 00:09:03,400
Uh, and uh, well that's, that's that's five gigabytes of data associated with this model.

173
00:09:03,400 --> 00:09:05,440
And that's going to take a minute to download.

174
00:09:05,480 --> 00:09:11,560
You can see the system memories coming up, but so far the GPU memory hasn't really moved at all.

175
00:09:11,720 --> 00:09:15,160
Uh, and this is looking like we're filling a lot of CPU.

176
00:09:15,360 --> 00:09:16,520
But fear not.

177
00:09:16,560 --> 00:09:21,920
Once this thing is loaded, it's going to slam over to the GPU and we're going to run against the GPU.

178
00:09:21,960 --> 00:09:24,840
Now hopefully you're doing this too because it's free, so why not?

179
00:09:25,080 --> 00:09:26,960
So you are currently running this.

180
00:09:27,000 --> 00:09:28,280
You press shift enter.

181
00:09:28,320 --> 00:09:35,600
You are seeing the stability AI model running for a class of students learning AI engineering in a vibrant

182
00:09:35,600 --> 00:09:36,840
pop art style.

183
00:09:37,280 --> 00:09:40,120
All right, I'm gonna I'm gonna vanish for a second.

184
00:09:40,160 --> 00:09:41,080
It'll be a few minutes for me.

185
00:09:41,080 --> 00:09:42,400
It'll be a second for you.

186
00:09:42,400 --> 00:09:45,080
And when I'm back, we'll see what comes of this.