-
Couldn't load subscription status.
- Fork 225
Add Zero-Shot Learning Notebook to Unit 11 #394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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. |
There was a problem hiding this 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
-Uin 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)
After that, we can merge and add the notebook!
|
Thanks for the feedback! |
There was a problem hiding this 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.jsonfile 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|
Hi , thanks for the feedback! |
There was a problem hiding this 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) | |
There was a problem hiding this comment.
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? 😄
There was a problem hiding this comment.
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.
There was a problem hiding this 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) | |
There was a problem hiding this comment.
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 😄
There was a problem hiding this comment.
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!
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.