Skip to content

Conversation

@Medissaoui07
Copy link

This pull request adds a new notebook titled "Zero Shot Learning" to Unit 11.
The notebook explains the concept of Zero-Shot Learning (ZSL), covering:

Introduction to Zero-Shot Learning

Explanation of seen vs unseen classes

How ZSL works using semantic embeddings

A practical example using a simple dataset and classifier

Visualizations and evaluation steps

This addition provides both theoretical background and a hands-on implementation to better understand ZSL.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@sergiopaniego sergiopaniego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the addition!! Really valuable!

We need to link this notebook in the Table of Contents for Notebooks to include it.

Some improvements for the notebook (sorry it's not easy to review it):

  • Add -U in the installation to retrieve latest versions: !pip install -q -U transformers datasets torch Pillow matplotlib accelerate torchvision
  • Typo in ...the Hugging Face Hub. ng. -> ...the Hugging Face Hub.
  • Let's keep indentation consistent (image)
image

After that, we can merge and add the notebook!

@Medissaoui07
Copy link
Author

Thanks for the feedback!
I’ve made the requested updates . Please let me know if there’s anything else to improve.

Copy link
Member

@sergiopaniego sergiopaniego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

We still need to make some small changes in order to approve and merge :)

  • We need to remove the setting.json file that has been added.
  • We need to link this notebook in the Table of Contents for Notebooks to include it.
  • The new indentation in the previously changed code snippet changes the workflow (code below). Please, double check it :)
num_classes = len(class_names)
        # Make sure we don't request more unseen classes than available
num_unseen = min(50, num_classes // 4) # Let's aim for ~25% unseen, capped at 50
if num_classes < 2:
    print("Error: Need at least 2 classes to perform a split.")
else:
    if num_unseen == 0 and num_classes >= 2:
        num_unseen = 1 # Ensure at least one unseen class if possible
        num_seen = num_classes - num_unseen

        # Shuffle the extracted class names randomly
        shuffled_classes = random.sample(class_names, num_classes)

        # Assign to seen and unseen lists
        unseen_classes = shuffled_classes[:num_unseen]
        seen_classes = shuffled_classes[num_unseen:]

        print(f"\nTotal extracted classes: {num_classes}")
        print(f"Number of 'unseen' classes for ZSL evaluation: {len(unseen_classes)}")
        print(f"Number of 'seen' classes: {len(seen_classes)}")
        # print("\nExample unseen classes:", unseen_classes[:5]) # Uncomment

@Medissaoui07
Copy link
Author

Hi , thanks for the feedback!
I hope now that everything is fixed. I'm ready for any other modifications.

Copy link
Member

@sergiopaniego sergiopaniego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Almost there!

| | [Image Labeling with BLIP-2](https://github.com/huggingface/computer-vision-course/blob/main/notebooks/Unit%2010%20-%20Synthetic%20Data%20Creation/image_labeling_BLIP_2.ipynb) | [Image Labeling with BLIP-2](https://colab.research.google.com/github/fariddinar/computer-vision-course/blob/main/notebooks/Unit%2010%20-%20Synthetic%20Data%20Creation/image_labeling_BLIP_2.ipynb) |
| | [Synthetic Data Creation with SDXL Turbo](https://github.com/huggingface/computer-vision-course/blob/main/notebooks/Unit%2010%20-%20Synthetic%20Data%20Creation/synthetic_data_creation_sdxl_turbo.ipynb) | [Synthetic Data Creation with SDXL Turbo](https://colab.research.google.com/github/fariddinar/computer-vision-course/blob/main/notebooks/Unit%2010%20-%20Synthetic%20Data%20Creation/synthetic_data_creation_sdxl_turbo.ipynb) |
| Unit 11 - Zero Shot Computer Vision | No Notebook | No Colab |
| Unit 11 - Zero Shot Computer Vision | [Zero-Shot Learning with CLIP](https://github.com/huggingface/computer-vision-course/blob/main/notebooks/Unit%2011%20-%20Zero%20Shot%20Computer%20Vision/zero_shot_learning_with_clip.ipynb) | [Zero-Shot Learning with CLIP](https://colab.research.google.com/github/huggingface/computer-vision-course/blob/main/notebooks/Unit%2011%20-%20Zero%20Shot%20Computer%20Vision/zero_shot_learning_with_clip.ipynb) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the notebook file here differs from the file name in the PR. Could we update either of them? 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that and sorry for the mismatch .I've updated the notebook name.

Copy link
Member

@sergiopaniego sergiopaniego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're almost there again!

Also, we need to remove .vscode/settings.json from the PR 😄 Thanks!

| | [Image Labeling with BLIP-2](https://github.com/huggingface/computer-vision-course/blob/main/notebooks/Unit%2010%20-%20Synthetic%20Data%20Creation/image_labeling_BLIP_2.ipynb) | [Image Labeling with BLIP-2](https://colab.research.google.com/github/fariddinar/computer-vision-course/blob/main/notebooks/Unit%2010%20-%20Synthetic%20Data%20Creation/image_labeling_BLIP_2.ipynb) |
| | [Synthetic Data Creation with SDXL Turbo](https://github.com/huggingface/computer-vision-course/blob/main/notebooks/Unit%2010%20-%20Synthetic%20Data%20Creation/synthetic_data_creation_sdxl_turbo.ipynb) | [Synthetic Data Creation with SDXL Turbo](https://colab.research.google.com/github/fariddinar/computer-vision-course/blob/main/notebooks/Unit%2010%20-%20Synthetic%20Data%20Creation/synthetic_data_creation_sdxl_turbo.ipynb) |
| Unit 11 - Zero Shot Computer Vision | No Notebook | No Colab |
| Unit 11 - Zero Shot Computer Vision | [Zero-Shot Learning with CLIP](https://github.com/huggingface/computer-vision-course/blob/main/notebooks/Unit%2011%20-%20Zero%20Shot%20Computer%20Vision/zero_shot_learning.ipynb) | [Zero-Shot Learning with CLIP](https://colab.research.google.com/github/huggingface/computer-vision-course/blob/main/notebooks/Unit%2011%20-%20Zero%20Shot%20Computer%20Vision/zero_shot_learning.ipynb) |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filename is Zero_Shot_Learning.ipynb and here is zero_shot_learning.ipynb, so we have to update either of them 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve fixed it now. Thanks again for catching that, and sorry for the mix-up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants