specifying how many classes you need and how many images per class.


Building a machine learning app | 10 hour coding livestream

Beautiful.


This is achieved by using URLs provided by ImageNet.


Wonderful.


Okay.


So the following command will randomly select 100 of ImageNet


classes, which at least 200.


This is what we want.


So we want to build a not food data set.


From each selecting class.


So let's go ImageNet class list.


How many foods are in here?


Food.


Food market, grocery store, market.


Okay, what we could do is we could download this.


And then randomly select, say, 500 classes or something and then delete the ones that are food.


Because that way we'll have a data set.


Is banana in here?


Banana.


I see.


Fruit.


Jackfruit, pineapple, apples.


Okay.


So that's that's what we need.


We need some data from ImageNet.


How about we do some data processing on this?


So.


More.


Let's start up a Python script.


Hello from Pakistan.


Hello from Peru.


You're looking good, brav.


Thank you, Adam.


I appreciate it, my friend.


Ashique, it's 3.45 a.m.


There.


Well, I appreciate you joining in, legend.


Banana, banana, banana.


Wait, why is this?


Downloading a video compute.


Hey, hey, hey, hey, hey.


I don't want to get that.


Why did that just download a CUDA repo?


We want.


Let's just download the zip of this.


Download zip.


What's in this zip?


Why not just download non-food images from the web?


Well, think about how many different non-food images we'd have to download.


Whereas we can just use this.


ImageNet.


So I'm going to need to copy this over.


So let's move this into downloads.


Actually, we'll move it to the desktop.


So we have ImageNet 1000 class IDX to label.


So yes, Ashique, I am connected to the deep learning PC via SSH.


You can see that there.


This is running on my deep learning PC downstairs.


Oh no, I don't need the Nvidia SMI.


Hello from Saudi Arabia.


Hello from Australia.


There we go.


We have a Nvidia Titan X GPU ready to go, but we have to do some data processing first.


So let's get to terminal.


We'll CD into desktop.


Oh no, we can just commit it.


So move ImageNet and then we want to move this to code food not food.


So now we're going to just add the ImageNet classes.


We'll commit this.


And then we can just pull that down on we could have secure copied that SCP, but we're going to just pull.


So now we've got ImageNet classes here.


Beautiful.


Okay.


So now we need to write some Python code.


To we want to get all of the classes in here that are not food that way we can build a data set.


We can download images from ImageNet that aren't food.


So if someone takes a photo of not food class, it will recognize it is not food.


Hello from Florida.


Hello from Iraq.


Oh, well, a Sheik you just wait the deep learning PC is going to be used a whole bunch.


We have a hundred people watching.


Thank you so much for tuning in.


Okay, so let's start to write some code and we can just probably manually go through all of these classes and delete them if they're if they're food.


Does that make sense?


And then we can get all of the ones that are not food and we'll download a hundred images of each and that way we'll have a pretty big data set of like 10,000 images.


And of course, this doesn't include everything in the whole world, but that's the idea of our model.


Is to learn a probabilistic relationship between what a food image of food looks like and what an image of not food looks like.


So let's create if you want to replicate this, this will all be on my GitHub.


And now let's open up this.


Data exploration. We want import pandas as PD import numpy as MP.


Import CSV.


Reinstall.


Hold on. Colonel, I want.


Okay, there we go.


And we want with open.


ImageNet.


Copy the path.


Dot read bytes as F F dot read lines.


We want ImageNet classes equals a list and then F dot read lines.


Is this going to work?


Might have to look up how to read a text file. ImageNet classes.


And one is going great.


Oh, did that work? Beautiful.


Okay, maybe we don't want to read it as bytes, so we don't have byte strings.


There we go.


Okay, read lines, but we don't necessarily want that.


We've got each one is a line.


Or we could just go ImageNet classes equals F dot read lines.


ImageNet classes. Beautiful.


This is a Jupiter notebook.


This is a Jupiter notebook running in VS code.


So there's a better way to do this.


Let's look that up. Python how to read in dictionary from TXT.


Dictionary from a file.


File open dictionary string.


AST literal aval.


Is this from the Python standard library?


Okay, we just want read.


F dot read.


And then.


Okay, beautiful.


We've got a list of ImageNet classes.


Now, hmm, who knows a good way to explore a dictionary?


In VS code, yes, you do get to press tab and get suggestions.


Look at this.


There we go.


VS code is very good.


Hello from Ivory Coast.


I don't even know what that is.


Let's look up Ivory Coast.


Ivory Coast.


Hello from Brisbane, Australia.


Wow, West Africa.


So good to see you.


Thank you for joining in.


That's amazing.


What does Ivory Coast look like?


Wow, that's beautiful.


How do you say this?


Cote de Lavorre.


Sounds French.


Okay, we're getting a bit distracted.


Let's go back to the code.


So we need a way.


Let's go through this and how do we edit a dictionary?


I mean, I turn a dictionary into, I want to remove, let's loop through this.


So for ImageNet classes, so we want for kv in ImageNet classes.items.


If v.contains banana, print k.


String has no attribute contains.


Python check if string contains string.


I thought find.


Does Python have a string contains substring?


Oh, in.


I'm too used to writing pandas.


If banana in v. 954.


Okay, so maybe we just go ImageNet food classes.


No way.


This guy Swaida Shah Kotha has built food not food.


Distinguished between food and non-food.


See, this is the beautiful thing.


Okay, how do they create a data set?


VGG 16.


How do they get the data set?


Food image data set, beautiful.


Look at this team.


We have so many different options.


Okay, well, that link is dead.


Look at that.


To develop an app that can distinguish between food and non-food.


We're going to extend this.


You know what?


We're going to come back to our friend,


Sida Shah Kotha at the end of this.


And once we've built it, we'll link in the app.


Come back.


He built the model but didn't build the app.


To do, come back to, how do you spell his name?


Said, Swaida Shah Kotha to say, we've built the app.


We're going to come back to this lovely person and say,


hey, you know what?


Thank you for getting that started online.


We're going to build upon it.


So what other foods are in here?


Apple, pineapple.


Is there meat in here?


Meat, egg, chocolate.


So this is how you got to go through crafting a data set.


So let's go Python list of common eaten foods.


Nope.


Hello from Turkey.


It's French, could pronounce it as Cote d'Ivoire.


I'll probably get all this wrong.


Hey, hey from Colombia.


Two people from Colombia.


Thank you so much.


What do you think about the new MacBook Pros?


Will first M1 generation be about, be enough for beginner, medium, DS and ML user?


Yeah, for sure.


The beginner ML, I mean, M1 is a fantastic machine.


I've got some of the new ones on order.


I'm going to test them out too.


So Python.


Here we go.


Closed.


Oh, here we go.


NLTK, you can get, what does this do?


This is beautiful.


We're just going to combine a whole bunch of different data here.


So USDA.


Food data.


Oh, we could work through this.


I've already got this data downloaded.


Let's try the NLTK method and then we'll come back.


Okay, we'll get this.


The food SysNet and WordNet.


So let's go food WordNet subset downloader.


Congrats on 100k.


Thank you so much.


Tray review.


That's what we're doing.


We're getting a data set of only non-food items.


And M1 with 16 gig of RAM is perfect to get started.


Full Flask multi-threaded download of images from ImageNet.


Okay, here we go.


So let's install NLTK.


WordNet.


Okay.


Let's do this.


Seeing 842, 843 AM freaked you out.


Yeah, it's nice and early here.


Let's try this out.


Let's install NLTK.


So what's the recommended installing NLTK?


So we need to install NLTK.


Nice and quick and we're going to download.


This is a very nice website.


Okay, so let's just save some steps.


Log downloaded ImageNet class list from GitHub and downloaded and installed NLTK.


Want to get non-food classes from ImageNet.


Installed NLTK to get to try and get a list of words associated with food.


This is our log clear LS.


We have was the ImageNet classes.


I'm just going to put this here.


This is so someone can replicate what we've done.


I'm just going to I want the code to be.


It's all going to be open source.


So I want someone to be able to replicate what we've done.


So let's let's now go back and figure out what this does.


So this is going to be.


We'll make it here food names from NLTK.


Hello Manas.


How are you?


Vamsee thought I was in California.


No, I'm in Brisbane Australia my friend.


Land down under so from what I understand.


Do I not have NLTK?


No module named NLTK.


We're going to have to do some environment refreshing.


NLTK.


Hey, why didn't that install NLTK?


Requirement already satisfied in site packages.


Hmm. I want to conda how to install in current and with pit.


It should install.


Yes. Okay. This is what I want.


Conda install pip.


That's what I need.


There we go.


Okay clear and now we want pip install NLTK.


Okay pip install.


Conda and list.


We want it in the current env.


Wonder if I can just install it from here.


Pip install NLTK.


Requirement already satisfied.


I don't want it in there.


Oh, there we go.


Import NLTK.


No module named NLTK. Classic.


Oh, I had to restart the kernel.


Machine learning.


Insist on neural network.


So neural network is just a function estimator.


Machine learning in a nutshell is you use machine learning to identify patterns and data or turn data into numbers.


Whatever data is could be words could be images could be videos could be text could be anything.


And then you use a machine learning algorithm to turn that data into numbers or a pre-processing algorithm to turn that data into some numerical representation.


Then a new machine learning algorithm such as a neural network or whatever will go through those numerical representations and find the patterns in there.


What the patterns are you define and what the patterns are that the machine learning model actually figures out it learns those patterns.


Okay, so let's see.


Oh, look at this team.


There we go.


Okay, we've got a list of classes.


This is wonderful.


Let's go NLTK corpus.


What's wrong with this?


It worked.


Turn the warnings off.


So look at this.


We've got a list of foods.


How long is this list?


I need some I need some space to code here.


So wordnet.py discarded redundant search for.


That's all right.


Food list.


Haha, look at this.


Now we've got a list of food items.


1600 food items.


Let's have a look through these.


So now we've got a list of food that we can we want to filter if the ImageNet class has any of these in it.


Look at this.


Tabasco chips, mashed potato, cut of pork, delicious, take away, puller, chocolate bar,


grey mullet, gammon, yogurt, brat.


Okay, this is wonderful.


We have a list of foods now.


So what we're going to do is.


Got a list of foods.


Now.


We have a list of foods.


Now to filter ImageNet data set classes and remove any class that contains a food.


So we can download images of non-food from ImageNet.


We're building a data set from scratch here people.


That way you can replicate this whole thing from machine learning model to data set building to everything.


So let's let's have a little bit more of a look here in our data exploration notebook.


We have a food list.


Let's just view the first 10.


So we have 10 and let's check if banana in food list.


True.


There we go.


There's a banana is our sanity check.


Check for banana in food list.


So now we want to filter the ImageNet data set.


So ImageNet data set, I believe doesn't have.


Okay, we need to strip.


Let's strip the strings.


From here.


We'll lower them all.


So they're all lowered and we'll get rid of the hyphens and any punctuation.


I think there's only hyphens and underscores and the same thing we'll do with this.


We'll get rid of the underscores and lower.


So filter non-filter food items out of ImageNet list.


Can I show time to time your RAM usage with activity monitor?


Yes, this is not on my M1.


This is this is on my MacBook 16 inch.


So memory.


I have 64 gigs of memory on here.


But remember, I'm streaming and doing a whole bunch of things and it's also going to use more memory if you have it.


So yeah, I have like Dropbox use it a lot and Windows Server and whatever.


That's all right. Filter foods out of here.


Thank you for the comment on the Mo, Siobhan.


I appreciate that.


So filter food items out of ImageNet list.


We want to have for food item in food list string food item.lower lower all the text.


No print.


Okay, and we want dot lower and we want to strip Japanese plum.


Hey.


No, what's the method?


What's the method to break a string on a certain thing?


Who knows this?


If you're not really sure where to start machine learning, you can go to my blog.


And go search for this Daniel Burke five steps to ML.


Right. There's a lot of a lot of shit out there on machine learning or whatever.


This'll this is pretty straightforward.


And split. That's it. Thank you.


And otherwise look up.


Look up the machine learning roadmap.


Thank you everyone.


For helping me with split machine learning roadmap.


Look at all this look at all these ads that are above me above there above there above there above there.


But look my GitHub machine learning roadmap.


Number one.


Good ads all these ads are above my post.


My post is machine learning roadmap number one on get on Google.


So thank you everyone. Let's use a split command.


The perfectionist am I getting the new MacBook Pro?


Well, I've got someone order. I'm going to test them out.


Split. Okay, there we go.


And we want.


So let's remove.


Move punctuation and lower.


We want.


Food list equals.


Food item got lower.


Got split.


For food item in food list.


OK, and now we need to create a list of.


Item for.


Food item.


For.


Sublist in.


This work.


Food.


Nope.


For sublist in.


No food for food item. That's what we're going to do.


A list of lists.


Food for food item. I always get this mixed up.


Python create a list from list of lists.


It's a sublist.


Their item for sublist in T.


Flat list equals.


Food item for.


Food list.


No, no, no, no. I got an idea.


So we got food list there.


Hey, what happened there?


So now let's flatten it out.


Flat.


So flat food.


List equals food for.


Food list in.


Food for food sublist in food list.


Into.


For.


Did we make it? We made it. OK, there we go. So we got flat food list. We've got a list of foods.


Now let's do the same for our ImageNet.


I'll make this all nice and clean before.


It's uploaded, but we got a flat food list.


But we only really want to see the first 10, don't we?


And every time we rerun these cells, it's going to override variables. So that sucks, but that's OK.


I really love you says I'm a noob and I hate guys who work in machine learning.


That's unfortunate, man. You're in the wrong stream.


So we have a flat food list. Now let's.


We want ImageNet classes.


So for KV in ImageNet classes.


If.


If V.


We need to split.


V.lower in.


Flat food list.


Print K. What's this going to do?


We need items.


Hey, there we go.


If V.lower.


So let's go.


Check.


ImageNet classes for foods.


So this is.


Our list of ImageNet classes.


And we want print KV.


What does this look like? Hen, quail, partridge, goose, snail, hare, sorrel, honeycomb, pinwheel, plate, pretzel, broccoli, cauliflower, cardoon, mushroom, strawberry, orange, banana.


So the banana sanity check is there. That's beautiful.


OK, let's now.


But V is also.


Multi level strings.


So we actually want.


Print V.lower.


And we want split.


On comma.


Yes.


And then we want the items from a list.


How do we retrieve the items from a list? Or maybe we can do a straight up comparison. Will that work?


No. OK, I need to go to the bathroom. I'll be back.


Dan, reflecting on your time in ML, what's the biggest highlight and lowest point so far?


I'll be back in a second and we'll answer that question.


And move net for BJJ.


Oh, that's an interesting one. One sec.


She's.


Okay, welcome back.


Muhammad says I've always wanted how to make do online using ML.


What's the easiest path?


Well, there is no such thing as the easiest path.


Well, it's like every path is easy if you choose your own.


So I could sit here and talk at length for how to do it.


But my only way is to actually just do it instead of thinking about and talking about it out loud.


This is like we're literally doing machine learning online right now.


So that's how I do it is I just think of something that I'd like to build and I build that thing.


But Siobhan said before, I really easily get overwhelmed when I try to do ML project.


Any advice or tip?


Just keep going till you get better.


Who knows?


I'm doing a live ML project right now.


I might get overwhelmed.


So we'll see.


Siobhan, reflecting on your time in ML.


What's your biggest highlight and lowest point so far?


Highlight is like right now.


Look at this.


How cool is this?


We can we can make machine learning apps to 100 people around the world and share the


code make it open source.


What's not to love about that?


Is machine learning course by Andrew Ong still relevant in 2021?


Yes.


The courses online these days are pretty good.


So like that's the beauty of online.


It like filters out the ones that are shit and the ones that are good pretty easily.


So a lot of people are doing a course and they rate it pretty highly.


I'm not saying anyone's course are rated pretty highly, but someone might be.


You know pretty quickly whether it's good or not.


So that's the beauty of code as well.


Code either works or it doesn't.


And if it's math, it either works or it doesn't.


So you can pretty quickly find out if a course doesn't work, if the code doesn't work.


So we're going to go back to coding.


I'll get more Q&A later, but we're on a bit of a roll here.


So I really want to start downloading a data set because I don't know how long the download


is going to take.


But for building projects, just do it.


You're far smarter doing than you are thinking.


For doing machine learning online, literally just don't you over thinking it.


Just start doing it.


Add code to your GitHub, write stuff on your blog or medium or whatever.


That's how you do it.


So we need a way to compare the strings here.


So what's the best way to extract items from a list in Python?


Get items from a list.


So I would like to compare if...


This is what I want to compare.


You all can help me with this.


This is what we're going to do.


This is a community driven project.


We have this string.


I want to compare that to the flat food list.


So flat food list looks like this.


I want to know if this item is in...


That's what we could do.


So we could get the ImageNet items.


And then we've got the...


Want to unpack.


How should we do this?


Python unpack a list.


String one.


If and down, code it out.


String one, string two, four.


I will save the...


The stream will be on my YouTube channel, yes.


String one, string two.


So we want...


We're doing some basic string manipulation here, people.


Remember, Abraham Lostfunction said, if you're building machine learning projects, spend


the first six hours preparing the data.


So we want string one, string two in string one.


So that's not going to work, right?


So not list.


We need to get...


We want to extract those strings.


So maybe we break this down.


Does understand what I'm trying to do.


So let's write this in pseudocode.


Thank you, Hatan.


I appreciate that.


I'm glad you like my shirt.


So look at ImageNet classes.


And then we want to get value from ImageNet classes.


String and then we want to see if value appears in flat food list.


Intersect could be a good one as well.


Oh, can we see weights and biases later too?


Yeah, let's do that.


We'll get the whole shebang.


We'll use weights and biases to track our experiments.


Good idea.


So let's try that, hey, that's a good idea.


Set.


I want to also strip.


Will this work if I go get rid of spaces?


Strip.


List has no...


I need to remove the strip.


Okay, that's what we're going to do.


We're going to create a list of...


Let's go print.


No space for space.


Load in mv.lower.


Okay, there we go.


We've got a way to do that.


And now we can turn that into a set.


Let's go...


A list comparison, that's what we could do.


Maybe we do that.


Intersect.


Let's try it up here.


Set.


Someone said intersect and they are amazing.


I'm pretty sure you're going to be right.


Intersection.


Nothing.


This needs to be a set.


Then iterate over the set.


Am I not doing this right?


Expand set intersection.


Do I need to assign it to a variable?


What's happening here?


Just join not not entirely sure what you want to do.


Do I need to turn this into a?


Hey, there we go.


Okay, my set set cut.


I've got the itchiest nose on Earth.


Oh, my low guys, what's going on?


There we go.


We got an intersection.


You need to turn things into list first.


So now what we could do is a set.


So let's go print, we're going to get image net class list equals


this.


I will go set.


net class set.


Someone said whoever said thank you big shout out to ever said use a set.


Didn't even think about that.


See that's the power of pythons built in type someone has thought about this before.


Okay, we got a set.


Now let's go.


We've got a flat food list.


And we're going to go image net class set dot intersect in flat food list.


Well done team look at that.


Okay, let's can this printing out.


What do we get?


Oh, look at that.


That's what's up.


Okay, now we need.


This is for foods.


So image net food classes, we want to filter these out.


equals an empty dictionary.


And now let's create this image net food classes equals or we want key.


K equals V.


And now let's have a look at the image net food classes.


There we go team.


We're on fish on fish on.


So now we've got our image net classes that are up here.


This is the full list of classes.


And this is all the ones that are related to food.


Well, not really actually.


How many we got?


We have 49 classes that are from image net with.


But I feel like we can get rid of some of these.


The manual filter.


That's what we might have to do now.


So I wonder what the best way is to filter a dictionary.


Let's have a look at this.


We're going to use our best judgment here team to what classes shouldn't be there.


Hen we could use hen there.


Rough, rough grouse.


What is rough grouse?


Oh, bird.


Well, that is that food or not?


We need to discuss this on the stream.


Is this a is a rough grouse?


Is that food or not?


Or is that a bird?


Because technically that is food.


But let's say this is are we classifying this as food or not food?


If you took a photo of that.


What do we reckon?


So let's remove non food classes manual sort.


It's food.


We can eat it.


It's a food.


Okay, depends on the culture.


We're classifying as it a food.


So going through image net food classes manually equals now we're going to create a list here.


Snail partridge, goose, snail, spinny lobster, crayfish, hare, sorrel almost reaching 77


minutes.


Can you hear me breathing too loud?


Should I turn the mic down here?


It's a product of food.


Okay, it's going to be food.


Chime bell gong.


Well, that's not a food, is it?


So 494 birds equals food.


Yes, you're right.


Salmon, bluejack, yes, puffer, puffer fish, blowfish, bow tie.


A bow tie is not a food.


So now we're going to have to get a little manual.


That's okay.


NLTK has done very well for us so far.


Chime belt frying pan, fry pan, skillet.


Now a frying pan on its own is not food.


So that's not food.


Honeycomb hook, claw, lighter, 626, lighter, you're right.


Pinwheel, pinwheel is not food.


Pot flower pot, no, 738.


Refrigerator icebox.


Well, it has food, but it's not actually a food.


Plate, that's an interesting one.


No, plate is not a food.


Bagel, hot dogs, there's hot dogs.


What's a cardoon?


Who knows what a cardoon is?


Cardoon, oh, is that a food?


Sunflower family, including the artichoke.


What the heck do I do with a cardoon?


Edible, a celery stalk.


Okay, popular ingredient in Italian dishes, so it's eatable.


Eatable, edible.


These are all foods.


Cliff, cliff, drop, drop off.


I don't know what that class is to do with, but let's filter it out if in doubt, filter


it out.


These are the classes we don't want.


Promontory headland, no.


Let's go 976, and I think that's gonna be it.


So now, you're right.


Pigs are food, but dogs are not.


Oh, look at that team.


You know what time it is.


Well, maybe you don't because you're joining in, but you know what that is.


That's 77 minutes.


We now have some surprises.


So let me just leave a note here of where we're up to.


So that's non-food classes manual sort.


We have tea as well.


Thank you.


Have the fabulous Georgia bringing me tea.


Thank you so much.


We have some surprises to give away, but I'm gonna leave a little note here.


We're gonna leave a little note.


Next, we've got non-food classes.


Remove non-food classes manual sort from ImageNet food classes.


And then we want to download ImageNet.


Then we want to filter non-food classes from ImageNet food classes, ImageNet classes.


And then download non-food classes from ImageNet downloader.


All right, that's what we're doing next, but now we have some surprises.


So thank you all so much for joining in.


I need to go to my website.


Oh, not Affinity Photo.


We'll quit that.


Cancel.


I have a blog post that I'm about to publish.


So if we go to Safari site, let me just publish this.


So then you can all have the link.


We have a 100k subscribers live stream celebration post, which is now public.


Everyone should be able to go to this.


If you go to www.mrdberk.com slash 100k subs, we have this.


So I'm gonna link this into the chat.


This is my way of saying thank you to you all.


So we have 100k subscribers live stream celebration.


You found the page of magic.


To celebrate 100k subscribers on YouTube, I'm doing a 10-hour coding live stream you


might even be watching right now.


Thank you so much for tuning in.


There are some goodies to go away.


So we have 50% off the first month of access to all Zero to Mastery Academy.


There's 100 codes there.


The first 100 people to redeem these codes will get 50% off the first month.


Beware for all of these.


If you do not cancel before the month ends, you will be charged full price.


So there's link number one.


You also get the first 100 people to sign up to Coursera's Google Data Analytics Professional


Certificate the month off for free.


Is this is this the right link?


Look at this special offer for Daniel Burke fans first month free.


If you sign up, there's 100.


There's 100 passes to this.


The link is at www.mrdberk.com slash 100k subs.


We have this and then we have 52% off my book Charlie Walks if you use the code 100k.


So all of these links we have the first 100 for each.


So 100 codes here for ZTM.


We have 100 free passes for the first month of Google's Data Analytics Professional Certificate,


which has been taken by 400,000 people around the world.


If you want to learn data analytics, this is one of the best courses and you get the


first month for free.


So you could do the whole thing for free by Google and 52% off my book.


So make sure you go check that out.


It's for the first 100 people.


Okay, once the codes are out, they're out.


So check out that page.


If anyone wants it, you're in.


And I'm going to put this in the description of the stream as well.


That way, edit and then get the free stuff slash surprises here.


So the links in the description and the link is in the chat.


Thank you all so much for joining in.


If you have any problems, let me know.


But there we go.


First month free Coursera's Google Data Analytics Professional 50% off the first month of all


Zero to Master Academy courses and 52% off my book, Charlie Walks.


So go and enjoy that.


That's the 77 minute surprise.


And of course, it's over an hour in so we have to do 10 push ups.


What was the rules?


We're going to make this fun.


We're getting back into code in a second, but we have 10 push ups, 10 squats, 10 kicks,


10 punches every hour.


Who wants to join in?


Push ups first.


Now squats, I just realised you can't really see me.


Why 52%?


Because if you add five plus two, it equals seven.


Nine, 10.


I don't know if that was 10, but we'll call it 10.


Now 10 kicks, five each leg.


We need to keep moving.


Otherwise we'll be sitting down for far too long today.


10 kicks, two, three, four, five.


Now 10 punches.


One, two, three, four, five, six, seven, eight, nine, ten.


One for good luck.


Okay.


Now another hour timer.


Oh, I got my breath up.


That's good.


Another hour timer.


Go and check out those links.


50% off ZTM, first month free on Google Professional Data Analytics, and my book is 52% off.


Valid for the first 100 people only.


And because you're here live, you get first pick.


Back to the code.


In another hour, we're going to do more moving.


So next we wrote our sales notes.


We're still building the data set.


Now this is important.


Back to Edward's loss function, Abraham's loss function saying, we haven't built any


machine learning code here yet because we're building a unique project.


And that, like the way we need to build a model is we can't build a model without data.


So this is what we're working on.


We're still collecting a data set.


So here, food breaks will come at some point.


If so, Hattan is saying, asking for bank account.


So you'll still need on both websites, Zero to Mastery and Coursera, you will need to


enter your credit card.


Again, read the T's and C's that I've put on here.


If you don't cancel your subscription by the end of the first month, you will be charged


for the full price for the second month.


That's the way these platforms work.


I don't manage the payment system.


So keep in mind if you want the free month, cancel before it refreshes.


So you can have 50% off the first month or you can have the first month free.


You do need to enter a credit card, but if you just want those first months, cancel before


it renews the second month.


So that's your warning.


Let's get back into code.


As for the book, you just buy it, you pay the price and you own the book.


Like the book's yours after that.


I'm going to refresh this T that the lovely and beautiful Georgia bought me.


Thank you.


Okay.


So we need to now, we have ImageNet classes, ImageNet classes.


There we go.


But we want to remove, we want to remove all of the non-food classes.


So ImageNet food classes.


Let's now update ImageNet manual filtered food classes.


We'll create another variable here.


We'll turn it into a dictionary.


So we've got a list of keys that shouldn't be in our ImageNet food classes.


So let's have a look at this ImageNet food classes.


We want just the first five so we can see what's going on there.


Slice, unhashable, tied.


What's going on here?


Oh, it's a dictionary.


So let's turn it into a list and we're going to turn this into that.


First five.


How do you view the first five items of a dictionary?


That's all right.


We can, we can work with this.


We'll work with this.


So now let's ImageNet food classes.


And so for kv in ImageNet food classes.items.


If k in, we have keys of non-food classes manual sort.


I'm going to get rid of that now.


So we're on here team.


In there.


If k in here.


No, if k not in.


That's what we want.


Don't want keys that aren't food from the manual sort.


What did I miss?


You were taking mock tests.


You want a shake.


We've got giveaways here.


So this is the giveaways.


www.mrdberk.com slash 100k subs.


There we go.


Thank you Georgio.


Dictionary is not ordered.


You're so right.


We want here ImageNet manual filtered food classes k equals v.


And now we have, we're going to put some mark down here.


Remove the manually filtered food classes from ImageNet food classes.


Some classes in ImageNet food classes weren't actually food.


So now we're going to manually filter them.


Beautiful.


So let's have a look at what our new dictionary is.


Wonderful.


And we've manually filtered the food classes now.


So this is the ImageNet food classes.


Length.


We have 39 manual filtered classes.


Tea is delicioso.


You can turn the key or values into a list and splice it.


So now what we have to do is we have ImageNet classes.


Get list of food and non-food classes from ImageNet.


So now what we want to do is compare ImageNet manual food classes from, we still have ImageNet


classes.


This is the overall list.


So now we want to go hey ImageNet non-food classes equals a dictionary.


And so for every key that's not in here, let's get a list of those keys.


So food class keys.


Now this is very hacky, right?


But it's working.


We can refine this later if we wanted to.


Got keys.


And we want a list of keys.


Food class keys equals that and let's have a look.


Food class keys.


We'll get the first 10.


Okay, wonderful.


So now we want ImageNet non-food classes is going to be, what is the length of our, how


many classes do we have?


Equals.


This is some simple data filtering here.


Hello, that's not it.


ImageNet classes.


We have a thousand.


Yeah, so now we want to remove the ones that are non-food.


So that and we go for KV in ImageNet classes.items.


If K not in food class keys.


ImageNet.


So we've got some just basic dictionary manipulation here.


Non-food classes.


Could this be optimized?


Yes, it could.


That might be an extension for one of you watching at home.


K equals V.


Now we have a dictionary now of non-food classes.


Look at that team.


Okay, and now let's get how many are there?


That makes complete sense because we have what?


We have 39 food classes.


So we've removed those from the list.


So now we have a list of ImageNet non-food classes that we can download to create.


What are we working on creating?


We're working on creating images of not food.


And images of food can be and from ImageNet photos that are food.


So now we have two dictionaries.


One is ImageNet manual filtered food classes and one is ImageNet non-food classes.


So how about we filter the strings that are in here as well?


ImageNet non-food classes.


Of course, there's going to be some overlap here.


There's probably going to be this is not a perfect data set for sure.


We could probably fix that out.


Chickadee.


I don't know what a chickadee is.


What is a chickadee?


Who knows what's in ImageNet?


Is that food?


That's probably food, but we're just going to leave that in there for now.


We've done enough filtering.


What tea is it?


We have this is Pu'er tea.


So Pu'er tea is a Chinese tea, a Chinese black tea.


And it's one of my favourites.


The Chinese really figured this out.


Pu'er tea.


That's what we're having.


Images.


It comes in cakes like this sometimes, but this is what I'm drinking.


Pu'er tea with some delicious milk and sometimes a little bit of honey in there, you know?


Well let's go back.


We're getting distracted from coding here.


Let's lower these strings and remove any.


Or do we want to lower them?


Let's just leave that at that.


So now let's see how our ImageNet class downloader works.


So let's write a notion.


Log.


Got.


List of food classes and non-food classes from ImageNet.


Now to figure out how to download non-food and food images from ImageNet.


Random samples and can also create a food dataset, food image dataset from food 101.


Random samples of images from different classes.


How many images of each do you think we should have?


I reckon 10,000 of each is a good idea.


Someone is asking, oh hello, greetings from Europe.


You have to sleep soon.


That's all right.


The stream will be on YouTube later.


I'm going to be here for a few hours.


Michael really loved this stream.


Keep at it.


You're my motivation while I'm coding as well.


Thank you so much, Michael.


I appreciate that.


I've been thinking about this for a while actually.


Should I, I've been streaming on Twitch, but should I just move it to this channel and


then just keep it all in one place and then I just have a live stream playlist where all


of my streams are in one place on YouTube?


Will that clog up the channel or is it better just to have everything like separated on


Twitch and whatever?


So let's get rid of this, get rid of this, get rid of this, get rid of this, get rid


of this, get rid of this.


Data downloader.


Okay, here's what we want.


The following will randomly select a hundred of ImageNet classes with at least 200 images


in them and start downloading.


Ah, so the class list here, we need it in where I list every class that appear in ImageNet


with the number of total URLs.


This CSV.


Maybe we should have filtered that on that, but that's all right.


We should be able to map things.


Okay.


Class ID, class name.


How many is this?


We could have filtered things off this, but that's all right.


That's probably what we should have done.


We can adjust it.


This is beautiful.


I like Twitch, we prefer separated.


Yeah, Twitch is, I think Twitch is still the better way to go.


Twitch and then upload it to the other channel.


So okay, this is probably a better list that we can filter on.


Let's come back.


This is a long list, but that's all right.


Food.


Well, food is a class in here.


We obviously want to filter that out.


We need the ID.


I'll be back in a second.


I need to pee again.


Is it enough for your course for machine learning and data science or should take, you can take


whatever you want.


Follow your curiosity.


My machine learning and data science course, do you need to take that?


Of course not.


Like this is, this is the thing.


There's a lot of resources out there, but it's usually best to just pick a couple and


practice on those.


So if you want to do Google data analytics, do that.


If you want to do my course, do that.


Try it out.


That's the beauty of like having a month free.


You can see if you like it.


If you don't cancel it.


Thank you very much.


We're going down.


YouTube is a source of income but like I don't rely on it so.


Maybe we should filter on these because these have the keys but that's alright.


So let's.


I should have really just read the docs on this but why read the docs when you can spend multiple hours just figuring stuff out.


Words.txt. Too big.


Classes in ImageNet. OK let's filter these out. Let's get this CSV file.


Raw.


Can we read this straight in with pandas? It's alright because we've got this.


We need the codes. I didn't realise that we needed the codes for downloading.


See how this takes in a class list of different codes.


Let's read the script.


OK.


So it takes in a class list.


Thank you Aditya. I really appreciate it.


Hattan if you want to do the Google data analytics course you can do it but if you've already done mine you probably don't need it.


Any tips on starting a YouTube channel? I just I make the videos that.


I like to watch. Need ImageNet keys.


That's my only advice for starting a YouTube channel. Need ImageNet keys.


Turns out the download script downloads using ImageNet class keys.


For example.


So we need to map.


Class keys to the classes that we want.


Let's download this CSV.


So we want. Let's put it in here.


Import pandas as CSV. DF equals PD.


We can read CSV straight from the URL.


Straight from the raw GitHub URL. That's alright.


Now df.head.


OK. There we go.


And now one of the beautiful things about VS Code as well as I believe it has a viewer.


Variables.


We can view the data frame. Look at this.


Hey look at that.


That's cool.


Food. OK. There we go. We can filter out.


Anything to do with food.


But we still have our food list from NLTK which is beautiful. So let's filter this out now.


See your tray review.


Thank you for joining in. I appreciate it my friend.


So now let's get the DF.


Food list.


We want the flat food list.


Once we build this data set team the model building will be the easy part.


So we want to now filter the pandas data frame if any of the class names contains.


Let's go DF class name.


What do these look like?


Vitamin C. OK.


Planking.


So this is PD dot read CSV.


Oh my bad.


That was a mistake. Import pandas as CSV. That was a mistake.


Class name.


Lower. OK.


Is there any spaces in these?


I think we can get a pretty good filter.


Look it's not going to be perfect but it's going to it's going to it's going to do.


So we want to now.


I'll lower all the strings.


No actually let's go.


Get the length of the F.


OK. 21000 rows. Let's see how many this filters out.


So filter data frame from food classes.


That was a glitch.


I don't know why it worked but yeah Georgio is correct.


I imported earlier as PD.


So DF. Non-food.


Equals DF.


Filter on DF class name.


No not contains.


We want to make this not.


Class name.


String. Contains.


That string that is in.


Float.


Hmm.


No duplicates.


We've got PD as PDs here. Panda says PD here.


So it seems that there's.


Bad operator not for float.


Ah how many names are in here you reckon.


OK so we've got a few.


Remove names.


OK there we go. We're on team. Fish on here.


So we got to remove all the ones that have food in them. So is food.


Once we build this model. We are on. This is going to be a beautiful model.


OK there we go.


String. Lower. Contains.


Let's lower all the strings.


There we go.


There we go. DF non-food.


How many did we filter out with that?


So we filtered out 19 classes with just the food string. So.


String.


Now we want to filter out.


OK so we filtered out a bunch of foods here.


So this is the non-food classes.


So we filter out about 1000 with that. So that's good. But now we also want to.


Let's go.


Because this is these class names.


DF.


Class names have underscores and whatnot.


So that's easy and is a perfect match.


So we want.


Let's go data frame filter column by.


Strings in list.


Yeah, is in.


Is in seems the best way to do it. Have I ever used PyTorch for projects? Not for a project, but I'm going to start using it actually.


I think we can work with this.


Yeah, here we go. This is what we want.


So we can standardize the text here. How about we change the.


Fishing troll.


I think we've removed enough classes actually.


It won't be perfect.


But let's start to download some data.


So this is.


So now we have two data frames, DF food and DF non food.


There we go. We have 1000 different classes of food. I'm pretty happy with that.


DF food.


Now we can remove some of these.


Which one shouldn't be in here?


There's probably a lot of these that could be removed.


But let's start to download some images and then we can.


Yeah, plate.


OK, that's close enough to just being all food.


So now what we can do.


Hey, Mehmet, how are you? Siobhan Jeremy Howard's in Brisbane. Yeah, I believe he lives. I live somewhere in Brisbane.


Not sure where.


So we can remove things like ball. OK, so that's going to be to do.


Because if you take a photo of a ball. That shouldn't be in there, should it?


Ball. Ball's a big one. What else have we got here?


Pinwheel.


Refrigerator. OK, let's start to remove some of these from.


Flat food list.


Not food.


OK, we're going to spend 10 minutes removing foods from this list or not in foods.


From this.


Let's get another timer. Where is that timer at actually? 21 minutes. OK, let's spend 10 minutes.


Mehmet, I appreciate that. 10 minutes filtering data. So you've never really worked on a proper problem if you haven't filtered data manually, have you?


So ball. Manually removing not foods from flat food list.


These are ImageNet classes as well.


Now, where did I view this from?


There we go. Make sure we open that.


Not food list. So we got ball, squash is a food, puppy. Puppies aren't food. Are puppies food?


In some countries, maybe not in my world.


Alligator.


If they're on the borderline, they can stay as food.


Periwinkle. What is a periwinkle?


It's a flower. Look at this.


I search for a periwinkle and I get ads for dresses.


Hey, how are you Mehmet? We're filtering, we're creating an app called Food Not Food.


So you can see the GitHub here and that'll have the link to the notion.


But essentially, we want to build an image classifier to take a photo of something that's food not food.


Right now, we're building a data set filtering ImageNet for photos that are food and aren't food.


Cockle. If things I don't know. Is dog food?


Let's put dog in here. I'm building this from my perspective.


Game.


Rat.


Okay, this is good. Most of these are food.


Grouper, runner, yellowtail, dolphinfish, yellowtail, croaker, mullet, mackerel.


Ball. Okay, ball is going to be filtered.


Bar. What's a bar?


Blade. Is blade, blade could be a cut of meat, but we're going to remove blade.


Crate, cross, delicatessen, duck.


Game, game's going garden. Garden's not a food.


Hand. Hand and head can be removed.


Hey, prison's learning jacket, not a food.


Oh, I believe we have some food here.


Wow, thank you so much.


Wow, Georgia just made me some food because we're about two hours into this stream.


This is this is going to be the ultimate test is I'm going to take a photo of this now and.


Will the app we're building food, not food.


So let me show you what the amazing Georgia has just made. We're going to filter some images in a second.


But let me look at this. Look at this deliciousness.


So this is our test for the app is will the app classify this as food or not food?


Thank you, Georgia.


So we have we're going to stop the Q&A in a second while I eat this food because I'm not going to be coding while eating food.


So we've got a test case now. Jacket, joint, joint, junk, key.


We want these.


Key.


We have an image now to test out.


Why not twitch today? Because we're celebrating 100K subscribers.


That food looks delicious, doesn't it? I'm excited to eat it. Oven pin.


Pinwheel.


Now, a plate is not food either.


We're going to be here for 10 hours, team, so we need to make sure that we're taking stock of what's going on. Plate not food.


Pot.


Not food.


Powder rack, refrigerator.


Saddle shank.


Spoon isn't food.


Spring steamer.


Stick.


Temple.


We're going to eat this food in a second. Tongue is tongue food. Tongue's food in some places.


Truck.


Turban.


Wedge. Wedges might be potato wedges.


We're creating a data set.


Orange ring.


Cornmeal, breakfast, meal, picnic, dinner, tea, stew, caramel, sweet, candy, dumpling, pudding, pastry, donut, jelly, marmalade, bread.


Challah, flatbread, pizza, toast. This is good. This is really good. Once we remove these, pretzels, sandwich, hot dog.


We're going to have a pretty good data set here.


Broccoli, squash, cauliflower.


Split pea, soy, cardone.


Okay.


This is working amazing. What is his Twitch channel name? Mr. D Burke, you're right. Coursera, oh thank you so much.


Hey Coursera, congrats on 100k subscribers. Thank you so much. I appreciate that.


I need to take a photo of that.


I got started learning data science on Coursera and now we're here.


By the way people, if you want a special deal on Coursera, don't forget to go to mrdburke.com.


Read the T's and C's there so you don't get charged more than you want, but we have some goodies.


50% off the first month, first month free of Coursera's Google data analytics, and 52% off my book Charlie Walks.


But let's go back to filtering data.


And Siobhan says, please let Georgia know that Stream Things food looks delicious.


The Stream Things food looks delicious, Georgia. Thank you.


Thank you.


I agree.


Okay, we're almost through this list.


Someone finished Udacity deep learning nanodegree. Congratulations. Massive effort my friend.


Okay, this is beautiful team. Look at this. We have, these are starting to be mostly all just food.


Preparing the data set, the modelling code and exploration will come soon.


Fennel, ginger, mustard, tobacco, egg. These are all foods. This is great.


Parmesan, honey, molasses, spatter, chilli, lasagna, oatmeal.


You got to remember though, this is going to be inspired by ImageNet data set.


So wherever that came from, cup, tea. Well, cup is not food.


Cup. That'll be a tough one to do.


Honeycomb, iceberg, mountain, ocean, rainbow, star, star, rock, shell.


These two aren't food either.


Once the timer goes off, we're going to eat, we're going to do Q&A.


So if you have any questions you'd like me to answer while eating, I'm not going to code while eat.


I don't eat while I use a computer, but I will eat while I talk to you.


Runner. What's a runner? I don't know. Let's remove that.


And pilot. Pilot is not a food.


Don't eat your pilots. If you're in, if you're in an aeroplane, don't eat your pilot.


You heard that here first.


Unless you can fly a plane.


This is good. We're nearly through. This is this list is about a thousand long.


Oh, look at that. It's food time.


We've got too many timers going on here.


It's going to be food time and then it's time to move again, which is beautiful.


So and we're going to stand back up because we're here for 10 hours.


How long we've been going for that to just over two hours.


We're going to get to the end of this thousand list. Ash, ash is not food.


We're making a data set to build food, not food.


Chickpeas, soy. OK, I'm pretty confident the rest of these are going to be all food.


Have you worked on a machine learning project?


If you haven't manually sorted a massive data set.


Rings going belly. Oh, it could be pork belly.


Sand. Sand is not food.


Done. OK, so that's next. Let's write this down.


So code next.


Answer QA.


While eating. So this is the test case food.


The beautiful Georgia has made me some food. We're going to that's going to be the test image for the.


The application food, not food, then filter out non-food items from.


Data frame manually sorted.


And then download.


Image net food and non-food.


Classes class images.


And then make data set of food and not food.


OK, we're on. We're going to take a break.


We're not going to code for the next however long it takes me to eat this food.


But look at this. This is some delicious food.


The Georgia is just made for me.


So if you have any questions, leave them in the chat and I'm going to be answering questions for the next 10 minutes or so while I eat this.


Oh, man, can we please do these streams often? Yes, I'm looking to stream far more far more in the future.


I'm going to keep building the app that I'm working on, which is called Nutrify.


Wow, look at this omelet mushroom.


In my country, the time is go backwards.


In Australia, everything goes backwards, man.


We barely even use words to communicate.


Like in Australia, we say like, yeah, yeah, yeah, is a valid reply in Australia.


Who's Georgia? Georgia is my girlfriend.


What would you say about reinforcement learning? I don't know enough about reinforcement learning.


I think it's very valuable.


Deep mind and open AI doing a lot of cool things.


But I don't know enough. I'm not skilled enough in reinforcement learning to comment.


And I haven't yet seen like a real big use case.


There was one in the state of AI report saying that reinforcement learning was used for what you call it was used for.


How do you say? Restocking restocking shelves at like a supermarket.


Hey, Daniel, good name, first of all, but you passed the TensorFlow certificate last week and just want to say thanks to the motivation.


Oh, man, that's so cool. Congratulations, legend.


Mehmet says, Am I from Australia? Yes, I live in Brisbane, Australia.


Kevin says, Where can I get that shirt?


I should have a store and sell this shirt.


Let's find out the brand of this shirt. Hold on.


The brand of the shirt, was there a girlfriend reveal?


Georgia has been on the stream a couple of times that she's bought me some tea and some food, but there was no like GF reveal.


No, the brand of the shirt is Otway. Otway clothing.


They look like they make some good stuff. Look at these guys. This is Australia.


You can buy some brown overalls. You can buy a jacket. But yeah, Otway is the brand of shirt.


OK, we're going to finish this food. I never eat in a rush, but we do have to get back to coding.


Let me get the chat back up.


We're just taking a short break to eat.


Can I show you my Notion setup?


I can, but I think organising like it should be if you're going to organise your files in something like Notion,


you should create it yourself. That way you know where to look for things.


This is delicious, Georgia. Thank you.


Dan, hi, how are you?


We're taking a little break to eat some delicious food before we get back into the stream.


How many calories


do I eat per day?


I would say somewhere between two and a half thousand and three thousand. I haven't measured in a couple of years though.


Am I making you feel hungry? Well,


you should have known that when you tune into a food not food app building stream.


No, I'm kidding.


How long we got left? Well, seven and a half hours left.


But it doesn't really matter. We'll just go to when we need to go.


Ten hours. Easy money.


Have I done anything with knowledge graphs before? I haven't actually.


I don't think I have. Maybe I have like without knowing it, but not knowledge graphs. I haven't used a knowledge graph before.


But graph neural networks are starting to become a real thing.


So possibly I will do that then.


I haven't had a need for it yet. I probably will once I get deeper into building Neutrify.


Hey, Ashik's eating breakfast too. Good on you, legend.


Siobhan says.


Congratulations on your success so far. Did you believe you would be here today?


You know what? Secretly, yes. But you can't really predict where you're going to be.


So. Like, I don't feel I really don't feel any different to how I did three years ago.


I'm just sort of now there's just the numbers are larger. Does that make sense?


Like, I'm still curious and I like creating and I like learning things, but it's just everything else has grown around that.


So I developed the habit of continually learning, continually creating, and then somehow the Internet has worked its magic.


And we're here today and people are watching all over the world. And I thank you a lot for that.


And so it's I always treat it as like a circle is like I create things to put it out there.


People respond to that. That that motivates me to keep creating. And it just goes on and on and on and on.


But there's never really been a hey, you know what? I really want to get to 100k YouTube subscribers.


Oh, you probably know that I didn't I don't really care about the number.


That's not to say that I don't care about the people who are subscribed.


Is that the number on the page will there always be a higher number on the page.


So it's now I'm at 100k. It's like, well, why don't I get to 200?


Well, for me, that doesn't really motivate me. It does for some people.


For me, it's just like, am I creating the things I would like to enjoy?


Am I having fun every day? That's that's my main criteria.


And I feel like if I'm having fun, the people on the other end of things will be having fun.


So who knows?


My only talent is getting very curious about something and then.


Following it for long periods of time.


Hell Hound started a TensorFlow course on Udemy a couple of months ago, but had to make a pause due to school.


Coming back next week, Regards from Mexico. All the best, my friend. Enjoy the course. It's a pretty big one.


We're tuning in Mexico. That's amazing.


Ariel, I just want to ask, I'm a software engineering student.


So all my programming knowledge and focus all this time is on data structures and algorithms and OIP.


How useful are they in ML? Well, 100 percent, that's useful.


So like that's what machine learning is. It's basically just writing algorithms to manipulate, to find patterns in different data structures.


Look at that. It's a time again. It is time to dance. It is time to move.


Oh, my gosh. Which tab is my timer on? There we go.


OK, we've got to stand up again because otherwise we'll be sitting down for too long.


But that's what machine learning is. It's like programming just with data.


So. Have I read about deep learning transformers? Yes, I have.


I'm going to make more materials on those in the future, so stay tuned.


Transformers are seeming to be the one of the universal architectures.


However, there was another paper the other day that started to say, like, hey, is it the transformer architecture itself providing the benefits or is it how you preprocess the data?


Am I working as a company, as a machine learning, deep learning engineer? So I work for myself as a machine learning engineer.


My main title at the moment is machine learning instructor, but I'm working on a project called Nutrify at the moment,


which is going to be my return back to being a machine learning engineer. Well, I'm a machine learning engineer now.


OK. Food is done. I'll be back.


I'm going to take this to the kitchen and then we come back encoding. All right.


OK.


OK, we're coming back up. Now, I just I just ate, so not going to move.


We'll do double movement next hour. OK, we're going back to code. Thank you for joining me with the food.


Let's get this over here. Let's get the chat back to where we need to go. Chat. Hello from Egypt.


Thank you. If you just finished the hands on machine learning book, what would you suggest to read next?


Any of Andre Berkov's books. So Andre Berkov, 100 page ML book.


I like these books, 100 page machine learning or Andre Berkov machine learning engineering.


Those are both two good books. You can read them both online for free. But now we are back to coding.


So I'm going to put a timestamp here, timestamp for when I transcribe this video,


the timestamp will show that I'm back into coding from the break. So timestamp here. OK, let's go.


We need to now remove we've got we created this manual list of not food list.


So if you're wondering what we're doing, we are building a data set of not food and food items.


And as we we learned from Abraham loss function, it's important when you're starting machine learning project.


To spend a lot of time preparing the data set. So that's what we're doing.


What happened to your Apple magic pad is still here. It's still here. I just like I like to use both now.


I found out I'm back to the mouse world so we can get rid of this not food list. Wonderful.


And we only want the top five. So we've answered the QA while eating. Well done.


So the next eating break is going to be in about three hours or so. So like one or one thirty.


By then, we'll be halfway through the stream.


Who reckons we can get this full app built by then?


Our limiting fact is going to be how long it takes to download food, download food images.


So now let's recreate our actual non food data frame again.


And the air food equals not in.


Is in.


I'm going to clean this up later, but it'll work. Remove even more not food items.


Does that make sense? Not in not food list.


So how many does that remove? We've got nine forty one. Let's just put this here.


Nine forty one. Good time. If you ever noticed that Apple look on.


This is going to blow your mind. I'm going to blow your mind for a second. I used to work for Apple.


And this is the Apple time. Every product on Apple's website demos with nine forty one.


Let's go Apple iOS 15. Every demo photo from Apple has nine forty one in there.


Ready? Nine forty one. Nine forty one. Nine forty one. Nine forty one.


You can't unsee this now. Nine forty one. Nine forty one. Nine forty one.


Does this even have nine forty one on here on the non Apple phone? Yes, it does. Nine forty one.


Nine forty one. Nine forty one. So fun fact about that.


Jack Arnold, thank you so much. I remember you from the beginning, my friend. Thank you. Good to see you here.


I appreciate it. Alex, yes, data pre-processing is very, very hacky, but that's all right.


We're going to we're going to make it. We're all going to make it. DF food remove.


Oh, my goodness. No, we need to have food not in.


Bullion series will be reindexed to match. OK, so now let's have a look at DF food.


OK, so we removed we removed about another hundred classes. That's good enough for me. So now we have DF non food and DF.


So let's get get list of non food and food class keys.


Let's go. This was this was made by going through.


By my criteria equals I asked myself. Is this a food? OK.


Still building the data set almost three hours in, but that's OK.


That's that's I wanted to make this as real as possible. So DF food.


ImageNet food. Class IDs equals DF food.


What are the column names? Let's cancel this. Get rid of that.


Sin ID. OK, that's what we want. DF food. Sin ID. To list.


We actually we want this as a dictionary. Yeah, that's a better option.


Is it class name?


What does that look like? Sin ID.


Let's go. This is what we can do. Turn it into a list.


And then combine them. To list and then we want.


There we go. OK, now this is our food.


We do order dick.


There we go. OK, we're on. So now we have.


We have the non food. We finally have split ImageNet 28000 non food items or sorry 21000 thereabouts and we have.


862. Food classes.


So who wants to now download some data?


Kevin, I really appreciate it brother.


Appreciate keeping it real. So yes.


Yeah, you're right, Alex. The 941 number is the iPhone was revealed at 941.


So now let's we've got we've got a dictionary of classes. We got to figure out now how to download them.


So let's open up a terminal.


We get the downloader script. So.


Have I started this?


We need a list.


Let's go to notion.


Updated list of ImageNet food and non food items.


To include.


ImageNet keys from.


Hey.


They have GitHub in there.


Notion now embeds GitHub's. That's cool.


OK.


So we want this script. Are we running? We're not running on here anymore. We can close that terminal.


LS.


Make the ImageNet downloader.


Let's go.


I need to give some claps to this Martins Frolov's.


Good morning, Renuka. Hello. Hello. Thank you for tuning in. Good to see you here.


I'm going to go ahead and load up the images per class. OK, so a lot of images and ImageNet have over a thousand images per class.


This is beautiful. What a great blog post.


I'm going to go ahead and load up the images per class.


Yeah, so it's only going to use flicker URLs. That's all right.


Let's go here.


The data downloader only uses flicker URLs.


Less than total ImageNet images.


Because ImageNet images are


downloaded with different URLs. However,


flicker URLs are most reliable.


I'm very excited to watch GTC next week. I haven't got one of the new MacBooks, but probably later.


Yannick, thank you so much for joining in. It's late in France. It's going to be recorded. Yes, it'll live on the channel after it's done.


May the force be with me. Thank you so much. I'll see you next time.


0.2 seconds per image. Wonderful.


How much space do I have on this machine?


OK, let's see.


Let's go to here. Let's clone the repo.


I actually want to move this folder now.


What's happened there?


Ah, I see. So we actually just want to move.


We're just cleaning up the repo here.


OK.


What's in the requirements.txt here?


So we want.


What requirements do we need?


It's all written in Python 3. That's beautiful.


Hey Noah, we're working on creating an app called Food Not Food. So we want to build a full stack machine learning app to allow you to classify whether a photo is of a photo of food or photo of not food.


And the notes that I'm taking are available in Notion and the code. Let me update the code.


So it's going to be full.


It's going to be deployed by the end of the stream.


Let's get out of some extra tabs.


How do we use this?


Python downloader.py. Let's just try.


What's data root?


OK, beautiful. So we need to create a folder of images.


Now let's just download a hundred random images or so into there.


Get rid of this shopping website.


Python.


Download it up high.


We're going to do a number of classes.


We'll just get five random classes.


Five and we'll also get 10 images per class.


Here we go. Scraping images. Look at that light brown held escapement diameter.


Yes, look at this team.


There we go. OK, so download it some images so ran a test command to download images from with.


So this was bash.


Now let's have a look at these images.


Oh, wrong machine.


I'm running this remotely.


So.


There we go. Look at this.


We've got some images now.


This is diameter.


And then the class is wonderful.


Look at this. We have images now.


That's from Herald.


What does this mean? I have no idea.


Light brown.


Beautiful eyes. OK, so now we need to care get rid of all of these.


Look, this is funny for image net. It's like why? How is this North Carolina?


Anyway.


OK, so we have data downloaded.


Greetings from Turkey. Hello, hello, hello.


Greetings from Brisbane, Australia.


So we have some images officially have some images. Let's oh, I didn't mean to close that, but that's all right.


We can get that back.


So now we want how do we get a list?


Of. See if we have here.


Image net food class ID's and date.


Oh, goodness. We need to run this all.


Is it going to error?


Wow, it didn't error.


There we go. OK, so we need to figure out how we can pass who knows who knows how to pass a list to a script like this, right?


Or can we just run this in?


Jupiter.


Python how to pass list to command line argument.


Who knows how to do this?


Are you from Adelaide? No.


Hey, they look like they're downloading from.


Image net to.


OK, so we can look like we can do.


Quibi Hello, hello. So we need to pass a list. We want.


We want this. We want this as keys.


We want to pass this list to our command line argument.


This is the keys that we want. What is this?


Let's get out of this. And let's get out of this torch.


And let's get out of this. We'll put that up there.


All right, so this is what we want to do. We want to pass somehow pass this giant list to this command.


Can you have an autograph? Sure thing.


We'll download 500 images from each of the selected class.


So.


Can you pass a list?


Can I just run this? From in here.


Python.


Hello from Seattle, WA in the USA.


Hey, thank you for the great content and training courses that helped me transition from software engineer to data scientist.


Wow, that's amazing with a large software company. Congratulations, my friend. I really appreciate that.


Oh, and don't forget people. Actually, I'm going to say that at the next hour is the surprises.


Don't forget the surprises. People want some surprises. Go and check out this link.


Hundred K subs given away free months and discounts and whatnot everywhere.


So this should this should work. I reckon. Let's go here.


We want.


Data root is going to be.


Let's try this.


Try to download images.


Now we want data root to be test images.


And then we can go enter.


Number of classes to be five and we want.


Images per class to be 10.


Test images does not at all because it's it's right here.


There we go. Desi Desi DS plant soil pipe Swedish maple windfall Buckeye.


There we go. OK, so that's downloading images there.


Now, wonderful. Let's try.


Test list.


OK.


Test list images.


I don't want to modify the original file.


Empty string.


There we go.


Hey, yeah, there we go.


Is it really live? Yes, I'm live here. I'm right here.


How are you?


Are there any content creators that I look up on YouTube doesn't have to be ML.


I watch RuneScape videos.


I'm live. I'm live. I'm right here.


It's not pre-recorded, my friend.


Ask me to hold up a number on my hand and I will show you that I am live.


Is this going to work? No.


OK, so we need a way to pass in.


A Python list.


Big fan, thank you so much.


So let's go. How to pass Python list to command line.


Who knows how to do this?


My goodness, the ads on this website.


Are any creators that I look up to on YouTube?


Is the stream going all right?


I just got like a bit of a lag spike.


That's what I need to do.


I'm going to use.


Download a script.


This is beautiful.


So we have a default type equals list.


Can you pass? Pass string from file to Python command.


Can I just pass in a list?


I'd like to do this.


I derp.


Done done done. Look at that.


Thank you, Alex. I appreciate it.


Someone saying add a.


There we go.


OK, fish on team test images.


Wedge.


Boom, look at that. OK.


I flag.


Should I? This is hmm.


This is what I'd like to do.


I'd like to export those these to a clock to a like a just a file, a text file.


And then can you use?


What's inside a text file in here?


Does that make sense?


OK.


Hmm.


This is not very pythonic, but we can try it.


So.


So let's create the big one that we want.


OK, now.


And now let's go food class.


There we go.


Beautiful.


So these are the food classes that we want to download.


Does this make sense?


I want to put this into a file and then with this command.


I want to or with this command.


I'd like it to download download the images or read it.


Is there a way to do that?


If I pass in a text file here.


Does that make sense?


So this is the command I'd like to do.


I'd like to do this, but then I'd like to pass in this.


Food class ID string.


Dot TXT.


Can you do that?


Someone let me know if we can do that.


Otherwise, we're just going to have to.


OK.


Who's ready to start downloading some images?


Let's just start downloading.


Let's just throw it to the wind and we can fix this up later.


Daniel tutorial was uploaded on official TensorFlow website, right?


Anyone can forward me that link, please.


What do you mean the tutorial on official TensorFlow website?


My tutorial or a tutorial on this?


How many images per class should we do?


Let's just start downloading some images, hey?


One pot dish says my tutorial was uploaded to an official TensorFlow website.


Was it?


Victor, what's going on?


If you find the link for that one pot dish, I'd love to have a look at that.


Let's create images, make the food images.


Let's make the data.


There we go.


And then we'll get non-food images in data as well.


OK, who's ready to download this?


How many images per class should we get?


If we have food.


If we have, we want to download, actually let's get non-food images from ImageNet first.


Non-food.


We have 20,000 classes here.


So non-food class ID list.


And so if we download, if there's 20,000 classes, we want, let's get at least 10 images.


Because that's going to be, if there is 10 images, that is.


It's going to be 200,000 images.


Data, non-food images.


You ready to try this?


Non-food images, use class list.


We need string.


I don't know if my TensorFlow tutorials on TensorFlow's website, but it's, if you just search Daniel Burke TensorFlow, you'll find all my TensorFlow stuff.


OK, let's download this.


Who's ready to download images?


In three, two.


Well, I just, I need to hold my fingers up correctly.


Three, two, one.


Let's download some images.


Oh, what did we miss?


Argument list too long.


Damn it.


Yeah, that string is 208,000 characters long.


What's the maximum length?


OK, I got this.


I got an idea.


We're just going to download random classes.


And then we're going to filter it on the back end.


Yes, that's a great idea.


So let's just download random images.


Data, we're going to make dir.


And then we can filter them.


This is genius.


Make dir data images, image net images.


So we're going to download random classes, let's do that.


Number of classes, let's do a thousand.


And the number of images.


Let's just execute this in the terminal.


We can just, all the filtering we've done, we can filter it on the back end.


So number of images per class, 100.


And number of classes, well, let's go 50.


So Python.


Python, we're going to go download it up high.


We're going to store the images in data image net images.


Oh, it needs to be data image net images.


Data root is number of classes.


Let's get 1000 or 500.


500 classes should be enough.


Let's go the whole hog, why not? 500.


1000 classes.


And then images per class.


So that's going to be 100,000 images potentially downloaded.


Should we do more classes or more images?


Let's do 50.


There we go. Ready? 3, 2, 1, let's start downloading data.


Oh, okay. Now this is going to download. It's going to take a while, of course.


So now image net images is filling up.


So we can filter this on the back end.


Heal. Okay, beautiful.


This is beautiful scraping stats.


Flick up.


65% success rate. So we're downloading images.


How can I concentrate 10 hours straight? Who knows? We're going to figure out.


I'm going to get a drink of water.


But we're now downloading images. So we're going to filter these images on the back end.


Oh, would you look at that?


It is time to do some push ups and dance around.


Started downloading images from image net.


Going to filter these on the back end into food images.


And non-food images.


Command used.


Downloading random images from 50 random images.


50 random images from 1000 random classes.


Then filter 1000 random classes and images into food, not food.


Beautiful. So this is downloading. It is now time.


We've got a 75% success rate from downloading images from Flickr.


So now let's do some push ups. And what are the rules? Let's come back to Notion.


10 push ups, 10 squats, 10 kicks, 10 punches. But this time we have to do double because we missed the last hour.


20 push ups, now we've got 20 squats.


Let's move this over here. Just a little time stamp. We are downloading images now.


Time stamp, downloading images.


20 squats.


8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20.


Beautiful. 10 kicks. We'll do 10 kicks each leg.


Because we need to do 20 total.


We could do a move net classifier for if I'm doing kicks or not, or punches.


Now we've got 20 punches.


Okay, it's water time for me.


We are downloading thousands of images.


We could end up with close to 50,000 images here.


So we're collecting a data set that's almost ticked off.


Then we have to model the data set, build the application and deploy.


Oh, please. Thank you.


Oh, would you look at that. Get the water delivered by a little fairy.


Thank you, Georgia.


Okay, we've done.


Surprises. Check out the free stuff.


The free slash discounted stuff.


Don't forget, I'm back online.


Oh, please don't tell me the download script has sent us offline.


Are we back?


If we're back, let me know in the chat.


Should we start building a model?


Am I back?


I'm back.


It got kicked off for a bit. Thank you so much for people saying that I'm back because I'm back.


We need to set another hour timer.


Okay, while this is downloading images, let's start to build a model.


And we should also, we need images of food as well. So we should get the food 101 data set.


All good again. Thank you so much.


So food images are downloading.


My shirt's coming undone.


It's not that kind of stream.


This isn't Twitch.


Not an e-girl.


Okay.


And so now we're downloading images.


We should start to get food 101 images or we could start to build a computer vision model.


Because once we get the data set is the biggest part.


Once we get the data set, the models are ready to go.


Do I have TensorFlow? Let's start looking into this.


Model building.


TensorFlow, yes.


TensorFlow config.


We have a GPU available.


That is what's up, but we need to silence the TensorFlow warnings.


Here we go. We go down to video Titan RTX.


Compute capability is 7.5.


Do we have Grady?


We don't have Grady.


How many images are we having?


This is what's up, team.


Bleeding heart.


Bobcat.


Okay, let's close that because that's going to use up a lot of memory.


But we need a data set before this.


Let's turn off TensorFlow warnings.


Daniel, do I watch cricket? Yes, I watch cricket. I love cricket.


There we go.


Turned off the TensorFlow.


Do we have TF Lite Model Maker?


We do have TF Lite Model Maker. Beautiful.


So because we want to deploy this model, we need to build a relatively small model.


Can we build the infrastructure for what we want to build and then just run the code once it gets in?


We are building.


No, we're just going to leave the images in the folder that they're in.


We're just going to load it off that with the TF load images.


TensorFlow load images.


We're just going to use something similar to this.


No TensorFlow. Keras image data set from directory.


This is what we're going to use.


Main directory.


And then we want to look up how to convert TensorFlow, convert saved model to TF Lite model.


Here we go. OK, let's look into how we convert. So we got data downloading over here.


And keep that running.


TensorFlow Keras.


We can save it to a saved model, put it into a TensorFlow Lite converter and get it out.


Well, you can just do it like that.


Let's convert the model. How easy is that to convert to TensorFlow Lite?


Well, let's start building a model, a sample one.


We need to load the datas.


Let's do the datas man. I want to move this into here.


I don't want that. I want TensorFlow.


OK. So we're going to keep downloading images. Looks like we've got about 7000 plus images right now.


Let's get rid of the warnings.


There we go.


Because our model is going to be binary classification.


We want.


Let's just make a classifier for aircraft or anvil.


Data. Let's create a small data set.


How many photos of aircraft do we have? Aircraft, anvil. Clear.


LS. Let's go move.


Copy and make the.


Model test images.


Copy. ImageNet images slash.


When I copy recursive. ImageNet images. Aircraft, aircraft or anvil.


Aircraft to model test images.


Cannot copy.


Ah.


So the files are a little bit too deep, but that's OK.


Do I know if there's a good method to convert Pytorch model to TF? Yeah, you can use O and NX.


Let's do aircraft versus anvil.


There we go. Clear.


If you want to convert Pytorch to TensorFlow or TensorFlow Lite, look up Pytorch O and NX to TF Lite.


Or something like that.


There you go.


This seems like a good guide.


That's how to convert Pytorch to TensorFlow Lite.


So now we've got a lot more images. Let's start to build a model, hey?


Everyone likes building models.


So, LS data.


So we have images of aircraft and anvil.


So it's like OS walk data.


Import OS.


What is it for files? No, for dir. Dir.


We need to make a gitignore. Let's add to gitignore.


Image folders.


So now we're going to build a model.


Now we have to explore our data files.


And this is a timestamp for model building.


I'm going to leave a timestamp for model building.


That way when I transcribe this later, we will have timestamps for model building.


Now, we want to find, let's go print files.


Wonderful. That's how many files that we have.


Hey, why is that not in OS Lister?


Data.


Okay.


Okay, good.


Now we want to.


Is there a way, does this make test size?


That was loud.


Let's move some random files into train and test.


So now we need to create train test.


We want aircraft.


What's the best way to do this?


We want to make a directory and model test images.


In data model test images and we're going to call this train.


And we're also going to make another one data.


Data model test images.


Test.


Okay, and now we need to.


Make splits of images.


So we want.


Aircraft and airplane in here, but we want random indexes.


So let's go import random.


But there's not the same amount of.


Images in each one is there.


So.


Let's get a list of images.


We'll do this the hacky way and then we'll do this the real way.


Aircraft images.


Hey show about what's going on.


Will you do data monitoring in this tutorial depends depends what data monitoring you're talking about.


Show about we are building a full stack machine application called food not food from scratch.


That means we're connecting collecting a data set and we are going to be modeling it and then deploying the model later on.


Equals okay, so we want to get random indexes from this and then move the rest.


That aren't in there.


How many images do we have James Scott? What's going on legend?


53 53. That's all right, so we can go.


Train split equals.


0.8 times length aircraft images.


42 OK, so we have 11 test images. That's all right.


Train split.


We want non pie.


Huh?


Wonderful.


Yeah.


6 hours to go.


But what we're what we're getting what we're seeing here now is that data building a data set does take the longest part.


So when you want to work on a custom custom project, you need to build a data set.


Now here's what we want to do. We want to get get random.


Indexes of.


Certain number from list of images.


So.


We want a list of images.


What's the random choice in Python?


Python random select K.


Sample, that's what we want.


Python random seed.


OK, let's go import random. I think we don't need an empire, I think.


Sample from aircraft images only want 10.


OK, and then if we do random seed.


Beautiful.


But then we want.


Yeah, that's what we can do. Randomly select.


Let's get the train split up here.


Train split.


Random sample train split.


Train image.


And then test image list equals.


Aircraft.


And then we want to get the ones that are not in.


Set.


I want the difference.


There we go.


And then we should have length.


So we've got a fair few images now. This is good.


Wonderful, OK, so now we want.


Def create train test list. Target.


We're going to function as this.


So now we want.


We're still downloading images people.


But now we need to pre process our data into training and test sets. Wonderful, there we go. OK, we're on.


Random sample.


We've got a list, a beautiful list.


Now we need a list of does that better be much better, wouldn't it?


So.


Target does.


Equals.


Data.


So then we can get that list. Now we need to create a function to move images.


So we want to move. We want to copy all of the images from.


Let's let's make another day.


Hey, Delah, what's going on?


Split well done, OK.


Now we can get rid of these.


Print image, do we want.


Beautiful.


OK, but we actually want the full file path there.


There we go, team, we've got lists of random images of training tests.


We're on a roll here.


Making training and test sets here, it's probably an easier way to do this, but.


There we go. We've got a way to move images into training tests, so let's now do the same.


So.


So I'm just moving.


Copy.


Is it copy to.


Python, I say to copy.


OK, copy to.


So we're going to make a target directory.


OK, I need another helper function here.


Congratulations.


Thank you so much.


Hi, Vineet. How are you?


We're still downloading lots of images here.


74% success rate.


This is beautiful.


Be back.


OK, I know what to do now.


Oh no, we need the reverse.


We need train test.


Oh, we got some more movement to do.


Wham says hi. Hi Lex, what's going on?


Tell Wham I said hi too.


So we need to actually I need to fix this up.


So we're going to do some movement in a second, but I'm going to finish this code.


We want make target directory.


No, we won't don't want that.


So we don't.


Care about that.


Target is going to be.


So.


So now we should have.


Aircraft.


And yes.


OK, we've got a way to make splits.


Do the twist.


Now let's copy all of them.


Beautiful OK, now we can build a model, but we need to move first.


We have a lot of images downloading right now.


Look at all that isn't that beautiful.


Nearly 1000 classes downloading.


OK, next is.


Make model datasets from train test folders and then next is.


Build model on train test.


Datasets and then.


Evaluate model.


Convert model to TF Lite for deployment.


OK, we're on we've got a data set.


Vanette yeah, I'm not doing much talking at the moment.


And the way we're going to check if the app works is in a few hours.


We're nearly halfway.


This is very exciting in a few hours.


We're going to check if the website that we build works on a an iPhone.


Or you can visit it.


Bring the desk up or actually.


I'll put it down.


We have the rules are.


Let's make a list of hours. How many hours have we done?


We're nearly at two five.


Let's go here.


Hours.


To do one, two, three.


Four, five, six, seven, eight, nine, ten.


We've done four hours so far.


Nearly at five actually.


On my clock it says five. How long does the stream say we've been going for?


Let me know in the chat.


But we have 10 push ups, 10 squats, 10 punches, 10 kicks.


Now we have squats.


One, two, three, four, five, six, seven, eight, nine, ten.


And ten kicks.


Let's bring this up.


Five each leg.


Move this chair so I don't belt myself.


Ten punches.


Now ten star jumps for fun.


We're going to put a time stamp in here.


A time stamp for train and test sets made for a test data set.


Time stamp.


And now 10 seconds of dancing.


Four hours 43.


So John, I am making a website called Food Not Food.


Which is going to use a machine learning model to predict whether an image is of food or not of food.


You can see all the code here.


And the notion is going to track all the notes.


Now I'm going to get some water.


Don't forget there is the live stream celebration.


If you want some good deals.


Hello window man what's going on?


You can get 50% off the first month of access to all zero to my studio academy.


First month free of Coursera's Google data analytics professional certificate.


So Coursera giving us a hundred free months for this.


So thank you Coursera.


And my book is 52% off.


So it's for 32.


So go check that out.


Read the T's and C's because if you don't unsubscribe you'll be charged for the second month.


I'm going to get a drink.


We're downloading about 50,000 images right now.


So the next thing is we want to make model.


We're going to build a model.


This is exciting.


Okay I need to clean up some of this stuff here.


I'll be back in a minute.


You got a bunch of your own.


You got a piece.


Okay let's set another timer.


Now we need to build a model.


Okay so we need to load the data.


Let's do that.


We're still downloading lots of images.


Load data.


Have we got TensorFlow?


Did you notice that we just we spent the first four and a half hours crafting a data set.


That's a big note in machine learning right.


If you want to build a custom project you need to create a custom data set.


And that's what I wanted to do with this project is rather than just start off and build a model straight away.


I wanted to have nothing ready and then just start building it from scratch.


So let's do that.


Import TensorFlow STF.


We're going to figure out how to load some data.


I think it's train data or train folder.


It can be a model.


We're building this is on a test images by the way.


Split.


This is a test model.


We're going to build the real model once all the images are downloading.


You see this little see this down here.


We've got our deep learning PC which is downstairs from here running very hard trying to download lots of images from the internet.


Hot dog not hot dog.


A Sheik we're about to start modeling.


Good timing.


We've got a test data set set up over here.


Not the official data set because we're still downloading images.


And if you want to know what we're building all the codes on GitHub.


And we're up to modeling now we're downloading thousands of images.


So let's let's start building a model.


Look how many images we have now.


Look at all these classes.


How cool is that.


But we're going to filter those in a second.


So we're building a binary classification model first.


I'm going to go load in data.


So train data equals TF carers utils image data set.


Actually I think I don't have the latest version of TensorFlow.


They only changed that in one of the recent ones.


So we're going to go train der.


We want what could be our batch size.


Batch size 32.


Does this give me a docstring.


Labels equals inferred.


Label mode color mode class names image size.


We want to do for two to four.


Then test data.


Found 86 files.


Look at all that.


That's a bunch of jargon.


We want to get rid of the runtime here.


I mean warnings.


We got data.


We got 86 training images and 23 testing images.


Aircraft versus anvil.


The first model that we're going to build.


First model time stamp first model time stamp first model.


The first model that we're going to build is just aircraft versus anvil.


And then we can scale it up to more classes with more data.


We'll make sure that the model is running fine with a small amount of data.


Build the first model.


I'm going to prefetch these data sets as well so they're nice and fast.


Train data equals train data dot prefetch and we want tf data.


We're lucky we got a big dog GPU because this is going to be.


OK, we can get some model code here.


Let's go base model.


Let's build an efficient net tf carers applications dot efficient net be zero.


Where's my docstring completion.


Docstrings.


Hey.


We'll just go to the docs.


If you're wondering what efficient net be zero is it's this model.


Efficient net.


Be zero.


This is efficient net convolutional neural network.


There we go.


This is what we have.


So it's an architecture from 2019.


But it's just a bunch of convolutional layers.


It's actually mostly purely convolutional layers.


So we're going to build a nice and easy one efficient net be zero to start off with.


We can of course scale this up as much as we want as we keep going.


Well, let's look this up in the docs.


TensorFlow efficient net be zero.


So we don't want to include the top because we want to put our own custom layer.


The top layer we're removing.


So that means where when you include the top layer these efficient net models from TensorFlow.


So the pre-trained ones.


They're pre-trained on image net already.


So we're going to instead of it outputting a thousand classes because that's what image net has a thousand different classes.


We want it to output two classes and in our cases our classes are aircraft and anvil.


So we're just going to change the top.


But we also want the weights are going to be from image net.


That's what we want.


And I think everything else can be.


That's about it.


Include top equals false.


Because then if we go it's going to download the base model.


See downloads this from Google.


Thank you.


And then we want to go.


Base model trainable.


So this right now it's trainable.


We want to turn trainable off.


That means we don't want to do any fine tuning.


Because if we download this model it's going to be hundreds of layers.


Let's have a look at that.


See how many layers that is.


So heaps of layers.


If we turn trainable to false.


Make model untrainable.


It means all of these base layers are going to come with the patterns that they get downloaded from.


And we're not going to adjust them when we train them on our own data.


So that means the patterns that this model the weights that this model has learned from image net are going to remain the same as when we downloaded it.


But oh we should use weights and biases.


Let's do that.


Before we train a model we're going to use weights and biases.


To track our experiments.


So make model untrainable.


We'll just construct the model first.


We can set that to false and then we want to build a functional model.


And input equals input layer.


It's tf.keras.layers.input.


Then the shape is going to be 224.224.3.


And then we want x equals base model.


Pass it the input.


And then we want x is going to be tf.keras.layers.


We want a global average pooling 2D.


On the export here.


Is that how you do it?


Where's the functional API?


That's what we need to look up.


TensorFlow functional API.


I can't remember the syntax.


Why not efficient net v2?


Oh we could do that.


Daniel says hi.


Oh good name.


Love from India.


Hello hello.


Can you post your GitHub link?


The GitHub link is here.


Five more hours to go team.


We're halfway.


Woo hoo.


Is that correct?


So we're not including the top layers.


So let's have a look at this.


What does this mean?


Where's the functional API?


Is this in the right place?


Is the syntax here correct?


There yeah it's correct.


I forgot the syntax for a bit.


I've been writing PyTorch code.


TensorFlow is a little bit different.


So you still don't understand the meaning of include top.


Let's go here.


So we're going to add a baseline whiteboard.


Look at all this bullshit ads.


Just give me a whiteboard.


There we go.


Okay so we have this as a model.


And it's got layers here.


Okay.


This is our baseline model.


And when we download it we get the whole thing.


Right.


But when we set include top.


We only get this section.


So include top false.


We get rid of that.


So we can put our own top on.


Which means we're going to have an image here of something.


And I know my face is in the way.


Hold on.


Let me move my face over here.


This is our input image.


That's going to go through the model.


And the model's layers all of these patterns here are going to be passed to our own layer.


So in the case of the pre-trained model it was trained on a thousand different classes.


Because you can see that here.


That's on ImageNet.


ImageNet is a data set with millions of images.


We're actually downloading a lot of them now.


And it has a thousand classes in there.


However with our problem we only want two classes.


Which is anvil or aircraft.


So we have the baseline model here.


Which is all these layers.


Poorly drawn.


But when we set include top to be false.


We remove that top layer.


Which says one thousand.


Right.


Classes.


And we only want to put our own layer on the top.


And say two.


So we still get all the power of the models.


What it's learned and it's different weights on different images.


But instead of outputting to decide is this one of a thousand classes.


We're deciding is this one of two classes.


Does that make sense?


So the same inputs. Same baseline here.


But now instead of outputting a thousand options.


We're outputting two options.


So that's what we're building at the moment.


And that's a very poorly drawn one.


But I've probably got a better illustration on my TensorFlow GitHub.


Ashique do you know where the slides are for the...


Ashique do you mind linking the slides to the...


Can you link the tutorial where we do...


What's it? Not fine tuning.


Feature extraction.


Can you link the feature extraction stuff in the chat please?


From the TensorFlow GitHub.


Now we're going to do an output layer.


Output layer equals tf.keras.


Oh!


Do we need to...


Could we use EfficientNet v2?


Let's compare them.


That's what we can use weights and biases for.


tf.keras.layers.dense


We want two.


Right? Because this is our top layer.


We only want two classes.


Oh no we actually want one.


Because we're going to use a sigmoid activation function.


Because we're doing binary class entropy.


Construct model.


Model 1 equals tf.keras.model.inputlayer


Now this is probably going to be busted.


Input layer, output layer.


Because there's probably an error here.


That's right I haven't even included x there.


Build a model. Do we need an activation function for the output here?


I don't think so.


I can't remember.


Now let's have a look at our model. Model 1.


What error did we get? Did we get error?


Yep.


Inputs to a layer should be tensors.


Why is that not working?


Oh input layer.


Oops.


There we go. Now let's have a look at our model.


From keras.tfkeras.utils.importplotmodel


Hey.


What's keras.utils?


Keras plot model.


To install py.


Oh we need to restart this.


Will that matter?


Yeah why not. We're going to install weights and biases anyway.


Let's start getting weights and biases ready.


This is a time stamp for getting weights and biases set up.


pip install


restart


That's alright.


Let's install this.


pip install py.


Weights and biases hey.


Did I do an uppercase K?


Oh I have to install a bunch of different things.


I have to install graph viz.


I'll be shocked if this works.


I'm going to just yolo install this.


There should be a yolo install.


There we go. Installed graph viz. Let's get weights and biases up and running.


Weights and biases tensorflow.


Clear. Weights and biases init paramedic.


Try the colab. Ok we're going to set up weights and biases to track.


Here we go. Weights and biases.


And we want hyperparameters defaults config. That's what we can do.


Yeah so they set up a config. This is going to be great.


That way we can compare efficient net v0 and efficient net 1.


Yeah I had to install a bunch of things for.