Lesson 2 official topic

change few lines of code from search_images_bing to search_images_ddg and remove the key* and rest should be the same :slight_smile:

This looks great :slight_smile: but i am confused regarding how to add the model.pkl into app.py and code(customize) it out

After many trial and errors i finally uploaded a working code to gradio in hugging face :smiley:

Here is a simple model to check if person is happy or sad .
I download the data.
I run the model on data (after removing failed links ).
I cleaned the data as taught in lesson 2.
I trained the model with cleaned data.
Exported into .pkl and uploaded it to gradio ( after a lot of effort and errors )


working Teddy/grizzly/black bear classifier here:


on my mac machine, I setup the env using conda and vscode

brew install git-lfs
conda init zsh
conda install fastai gradio scikit-image
1 Like

I am sorry. I have just seen this message.

Nice one

Hi everyone, hoping someone can help me with this. I’m following along this lesson on YouTube and in the book and have gotten to the section where we are exploring the different Resize methods. I can get the the Resize transformation methods to work, but can’t seem to get the RandomResizedCrop to work. The images are not being resized or cropped.

I’ve tried multiple things, like re-creating the Datablock, and downloading other images… but can’t seem to get it working. Here is my code:

bears = DataBlock(
    blocks=(ImageBlock, CategoryBlock),
    splitter=RandomSplitter(valid_pct=0.2, seed=42),

bears = bears.new(item_tfms=RandomResizedCrop(256)) 
dls = bears.dataloaders(path)
dls.valid.show_batch(max_n=4, nrows=1, unique=True)

I have gotten it to work when I run it on one image though…

grizzly_bear = PILImage.create('grizzly_bear.jpg')

crop = RandomResizedCrop(256, min_scale=0.05, max_scale=0.15)
_,axs = plt.subplots(3,3,figsize=(9,9))
for ax in axs.flatten():
    cropped = crop(grizzly_bear)
    show_image(cropped, ctx=ax);

Has anyone facied this issue before? Thank you in advance.

I think the issue is that you are trying to show a batch from the validation set, where we do not perform data augmentation (RandomResizedCrop).
So, instead of

dls.valid.show_batch(max_n=4, nrows=1, unique=True)

you will see the differences when showing a batch from the training set, i.e.

dls.train.show_batch(max_n=4, nrows=1, unique=True)

Hope that helps!

1 Like

This worked. Thank you :pray:

Hi I was working through the video tutorial to create my own web application, I am at the stage where I create the app.py file for the HuggingFace space

After that when I clicked the tick in vscode that would allow me to push, then I got a notification saying that there are no standing changes to commit or something like that, I proceeded anyway and refreshed my hugging face page but the basic application did not show up

can I get some help, Thank you

Hi guys I was also trying to get fastai and python setup and having the following problem where mamba is unavailable and i don’t know why, I even attempted restarting the terminal can I please get some help, i am very new to this

Hello everyone!

Just got a question about using other fastai datasets.

I’m trying to replicate the pet classifier with the flowers dataset. And making it into a hugging face space.

However I’m getting errors when using the pkl model on the site. Am I jumping to far head in the course?

So far I’m just finishing lesson 3.

Can anyone help with setting up huggingface key? That’s the last step i’m missing before uploading the image detector code on huggingface. I’ve already tried following their instructions on their website… going to move onto lesson 3 first, thanks all!