From bbacf12b9041bc2ea1b3ddd1cbb2833d002d3ab6 Mon Sep 17 00:00:00 2001 From: Kadir Nar Date: Thu, 25 Jan 2024 16:48:00 +0300 Subject: [PATCH 01/11] =?UTF-8?q?=F0=9F=93=B0=20Update=20about.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tasks/src/tasks/image-classification/about.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/tasks/src/tasks/image-classification/about.md b/packages/tasks/src/tasks/image-classification/about.md index 04169331f2..6674c3482f 100644 --- a/packages/tasks/src/tasks/image-classification/about.md +++ b/packages/tasks/src/tasks/image-classification/about.md @@ -16,12 +16,14 @@ With the `transformers` library, you can use the `image-classification` pipeline ```python from transformers import pipeline -clf = pipeline("image-classification") -clf("path_to_a_cat_image") - -[{'label': 'tabby cat', 'score': 0.731}, -... -] +image_classifier = pipeline(task="image-classification", model="microsoft/resnet-50") +image_classifier("path_to_a_cat_image") + +[{'label': 'Egyptian cat', 'score': 0.7005051970481873}, + {'label': 'tabby, tabby cat', 'score': 0.16163259744644165}, + {'label': 'tiger cat', 'score': 0.04507654905319214}, + {'label': 'lynx, catamount', 'score': 0.011848953552544117}, + {'label': 'bucket, pail', 'score': 0.009444382973015308}] ``` You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to classify images using models on Hugging Face Hub. From 47409b8a41891a47024b9ae5c15f0124df4cb714 Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 5 Feb 2024 20:13:57 +0300 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=93=B0=20Update=20classification=20?= =?UTF-8?q?model=20results?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/image-classification/about.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/tasks/src/tasks/image-classification/about.md b/packages/tasks/src/tasks/image-classification/about.md index 6674c3482f..3ff3be6f09 100644 --- a/packages/tasks/src/tasks/image-classification/about.md +++ b/packages/tasks/src/tasks/image-classification/about.md @@ -17,13 +17,10 @@ With the `transformers` library, you can use the `image-classification` pipeline ```python from transformers import pipeline image_classifier = pipeline(task="image-classification", model="microsoft/resnet-50") -image_classifier("path_to_a_cat_image") +image_classifier("IMAGE_PATH") [{'label': 'Egyptian cat', 'score': 0.7005051970481873}, - {'label': 'tabby, tabby cat', 'score': 0.16163259744644165}, - {'label': 'tiger cat', 'score': 0.04507654905319214}, - {'label': 'lynx, catamount', 'score': 0.011848953552544117}, - {'label': 'bucket, pail', 'score': 0.009444382973015308}] + {'label': 'tabby, tabby cat', 'score': 0.16163259744644165}] ``` You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to classify images using models on Hugging Face Hub. From 7454ae9065b5bb37d7a6fbe932457b4f38dc3743 Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 5 Feb 2024 20:53:12 +0300 Subject: [PATCH 03/11] =?UTF-8?q?=F0=9F=8C=A0=20Add=20device=20parameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/depth-estimation/about.md | 2 +- packages/tasks/src/tasks/image-classification/about.md | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/tasks/src/tasks/depth-estimation/about.md b/packages/tasks/src/tasks/depth-estimation/about.md index b83d60e24f..ed260e2ad2 100644 --- a/packages/tasks/src/tasks/depth-estimation/about.md +++ b/packages/tasks/src/tasks/depth-estimation/about.md @@ -15,7 +15,7 @@ With the `transformers` library, you can use the `depth-estimation` pipeline to ```python from transformers import pipeline -estimator = pipeline(task="depth-estimation", model="Intel/dpt-large") +estimator = pipeline(task="depth-estimation", model="Intel/dpt-large", device=0) result = estimator(images="http://images.cocodataset.org/val2017/000000039769.jpg") result diff --git a/packages/tasks/src/tasks/image-classification/about.md b/packages/tasks/src/tasks/image-classification/about.md index 3ff3be6f09..5a95da8c56 100644 --- a/packages/tasks/src/tasks/image-classification/about.md +++ b/packages/tasks/src/tasks/image-classification/about.md @@ -16,11 +16,12 @@ With the `transformers` library, you can use the `image-classification` pipeline ```python from transformers import pipeline -image_classifier = pipeline(task="image-classification", model="microsoft/resnet-50") -image_classifier("IMAGE_PATH") +image_classifier = pipeline(task="image-classification", model="microsoft/resnet-50", device=0) +result = image_classifier("IMAGE_PATH") +result -[{'label': 'Egyptian cat', 'score': 0.7005051970481873}, - {'label': 'tabby, tabby cat', 'score': 0.16163259744644165}] +# [{'label': 'Egyptian cat', 'score': 0.7005051970481873}, +# {'label': 'tabby, tabby cat', 'score': 0.16163259744644165}] ``` You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to classify images using models on Hugging Face Hub. From 5537585901c25384fc6219bdc42ea0f44576eb4b Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 5 Feb 2024 21:06:23 +0300 Subject: [PATCH 04/11] =?UTF-8?q?=E2=AD=90=20Add=20device=20and=20model=20?= =?UTF-8?q?parameters=20to=20image-segmentation=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/image-segmentation/about.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/tasks/src/tasks/image-segmentation/about.md b/packages/tasks/src/tasks/image-segmentation/about.md index 4a8a45a195..b8048e51d6 100644 --- a/packages/tasks/src/tasks/image-segmentation/about.md +++ b/packages/tasks/src/tasks/image-segmentation/about.md @@ -32,8 +32,10 @@ You can infer with Image Segmentation models using the `image-segmentation` pipe ```python !pip install timm -model = pipeline("image-segmentation") -model("cat.png") +model = pipeline(task="image-segmentation", model="CIDAS/clipseg-rd64-refined, device=0) +result = model("cat.png") +result + #[{'label': 'cat', # 'mask': mask_code, # 'score': 0.999} From da8ce175848349d07851231355c7975fce71f05c Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 5 Feb 2024 21:09:28 +0300 Subject: [PATCH 05/11] =?UTF-8?q?=F0=9F=A4=A9=20Add=20device=20and=20model?= =?UTF-8?q?=20parameters=20to=20object-detection=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/object-detection/about.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tasks/src/tasks/object-detection/about.md b/packages/tasks/src/tasks/object-detection/about.md index 4dda21224f..3dd68d059b 100644 --- a/packages/tasks/src/tasks/object-detection/about.md +++ b/packages/tasks/src/tasks/object-detection/about.md @@ -21,9 +21,9 @@ Object Detection models are used to count instances of objects in a given image, You can infer with Object Detection models through the `object-detection` pipeline. When calling the pipeline you just need to specify a path or http link to an image. ```python -model = pipeline("object-detection") - -model("path_to_cat_image") +model = pipeline(task="object-detection", model="facebook/detr-resnet-50", device=0) +result = model("path_to_cat_image") +result # [{'label': 'blanket', # 'mask': mask_string, From 157276e9506caa4b9e6d71c4a9ae2967a047a27d Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 5 Feb 2024 21:13:17 +0300 Subject: [PATCH 06/11] =?UTF-8?q?=F0=9F=97=9E=EF=B8=8F=20Update=20the=20na?= =?UTF-8?q?me=20of=20the=20image=20parameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/image-classification/about.md | 2 +- packages/tasks/src/tasks/image-segmentation/about.md | 2 +- packages/tasks/src/tasks/object-detection/about.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tasks/src/tasks/image-classification/about.md b/packages/tasks/src/tasks/image-classification/about.md index 5a95da8c56..c5a9a3f3fe 100644 --- a/packages/tasks/src/tasks/image-classification/about.md +++ b/packages/tasks/src/tasks/image-classification/about.md @@ -17,7 +17,7 @@ With the `transformers` library, you can use the `image-classification` pipeline ```python from transformers import pipeline image_classifier = pipeline(task="image-classification", model="microsoft/resnet-50", device=0) -result = image_classifier("IMAGE_PATH") +result = image_classifier(IMAGE_PATH) result # [{'label': 'Egyptian cat', 'score': 0.7005051970481873}, diff --git a/packages/tasks/src/tasks/image-segmentation/about.md b/packages/tasks/src/tasks/image-segmentation/about.md index b8048e51d6..b5aae0f166 100644 --- a/packages/tasks/src/tasks/image-segmentation/about.md +++ b/packages/tasks/src/tasks/image-segmentation/about.md @@ -33,7 +33,7 @@ You can infer with Image Segmentation models using the `image-segmentation` pipe ```python !pip install timm model = pipeline(task="image-segmentation", model="CIDAS/clipseg-rd64-refined, device=0) -result = model("cat.png") +result = model(IMAGE_PATH) result #[{'label': 'cat', diff --git a/packages/tasks/src/tasks/object-detection/about.md b/packages/tasks/src/tasks/object-detection/about.md index 3dd68d059b..f959d99d39 100644 --- a/packages/tasks/src/tasks/object-detection/about.md +++ b/packages/tasks/src/tasks/object-detection/about.md @@ -22,7 +22,7 @@ You can infer with Object Detection models through the `object-detection` pipeli ```python model = pipeline(task="object-detection", model="facebook/detr-resnet-50", device=0) -result = model("path_to_cat_image") +result = model(IMAGE_PATH) result # [{'label': 'blanket', From 06f087a9ab924e32ac8edae3c104b6368d010dff Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 5 Feb 2024 21:16:02 +0300 Subject: [PATCH 07/11] =?UTF-8?q?=E2=AD=90=20Add=20device=20and=20model=20?= =?UTF-8?q?parameters=20to=20=20video-classification=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/video-classification/about.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tasks/src/tasks/video-classification/about.md b/packages/tasks/src/tasks/video-classification/about.md index 0436a873d3..21c4cfb74e 100644 --- a/packages/tasks/src/tasks/video-classification/about.md +++ b/packages/tasks/src/tasks/video-classification/about.md @@ -17,7 +17,7 @@ Below you can find code for inferring with a pre-trained video classification mo ```python from transformers import pipeline -pipe = pipeline(task = "video-classification", model="nateraw/videomae-base-finetuned-ucf101-subset") +pipe = pipeline(task = "video-classification", model="nateraw/videomae-base-finetuned-ucf101-subset", device=0) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/basketball.avi?download=true") #[{'score': 0.90, 'label': 'BasketballDunk'}, From 0469157dd7a0089b9c9ab61a26744fc165d08986 Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 5 Feb 2024 21:20:00 +0300 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=92=AF=20Add=20device=20parameters?= =?UTF-8?q?=20to=20zero-shot-image-classification=20pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tasks/src/tasks/zero-shot-image-classification/about.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/tasks/src/tasks/zero-shot-image-classification/about.md b/packages/tasks/src/tasks/zero-shot-image-classification/about.md index 0c4b283280..8fd02c9362 100644 --- a/packages/tasks/src/tasks/zero-shot-image-classification/about.md +++ b/packages/tasks/src/tasks/zero-shot-image-classification/about.md @@ -32,7 +32,8 @@ The model can be loaded with the zero-shot-image-classification pipeline like so from transformers import pipeline # More models in the model hub. model_name = "openai/clip-vit-large-patch14-336" -classifier = pipeline("zero-shot-image-classification", model = model_name) +device_name = 0 +classifier = pipeline("zero-shot-image-classification", model = model_name, device = device_name) ``` You can then use this pipeline to classify images into any of the class names you specify. You can specify more than two class labels too. From eea1ad37a5ea4c31fc3410dbf6e7065d955e4b56 Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 5 Feb 2024 23:15:29 +0300 Subject: [PATCH 09/11] =?UTF-8?q?=F0=9F=8D=80=20Update=20image=20segmentat?= =?UTF-8?q?ion=20model=20in=20about.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/image-segmentation/about.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/tasks/src/tasks/image-segmentation/about.md b/packages/tasks/src/tasks/image-segmentation/about.md index b5aae0f166..0c6e1e3895 100644 --- a/packages/tasks/src/tasks/image-segmentation/about.md +++ b/packages/tasks/src/tasks/image-segmentation/about.md @@ -32,7 +32,10 @@ You can infer with Image Segmentation models using the `image-segmentation` pipe ```python !pip install timm -model = pipeline(task="image-segmentation", model="CIDAS/clipseg-rd64-refined, device=0) + +from transformers import pipeline + +model = pipeline(task="image-segmentation", model="facebook/detr-resnet-50-panoptic", device=0) result = model(IMAGE_PATH) result From 71cf6a4879ecc095be54fe388d9303fe251bced1 Mon Sep 17 00:00:00 2001 From: kadirnar Date: Sun, 11 Feb 2024 10:20:25 +0300 Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=93=B0=20Update=20documentation=20p?= =?UTF-8?q?arameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/image-segmentation/about.md | 4 +++- packages/tasks/src/tasks/video-classification/about.md | 2 +- packages/tasks/src/tasks/zero-shot-classification/about.md | 2 +- .../tasks/src/tasks/zero-shot-image-classification/about.md | 4 ++-- packages/tasks/src/tasks/zero-shot-object-detection/about.md | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/tasks/src/tasks/image-segmentation/about.md b/packages/tasks/src/tasks/image-segmentation/about.md index 0c6e1e3895..6851a7b85a 100644 --- a/packages/tasks/src/tasks/image-segmentation/about.md +++ b/packages/tasks/src/tasks/image-segmentation/about.md @@ -30,9 +30,11 @@ Panoptic Segmentation is the Image Segmentation task that segments the image bot You can infer with Image Segmentation models using the `image-segmentation` pipeline. You need to install [timm](https://github.com/rwightman/pytorch-image-models) first. -```python +```bash !pip install timm +``` +```python from transformers import pipeline model = pipeline(task="image-segmentation", model="facebook/detr-resnet-50-panoptic", device=0) diff --git a/packages/tasks/src/tasks/video-classification/about.md b/packages/tasks/src/tasks/video-classification/about.md index 21c4cfb74e..8d74906105 100644 --- a/packages/tasks/src/tasks/video-classification/about.md +++ b/packages/tasks/src/tasks/video-classification/about.md @@ -17,7 +17,7 @@ Below you can find code for inferring with a pre-trained video classification mo ```python from transformers import pipeline -pipe = pipeline(task = "video-classification", model="nateraw/videomae-base-finetuned-ucf101-subset", device=0) +pipe = pipeline(task="video-classification", model="nateraw/videomae-base-finetuned-ucf101-subset", device=0) pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/basketball.avi?download=true") #[{'score': 0.90, 'label': 'BasketballDunk'}, diff --git a/packages/tasks/src/tasks/zero-shot-classification/about.md b/packages/tasks/src/tasks/zero-shot-classification/about.md index 9b7ff3c48c..30a489015c 100644 --- a/packages/tasks/src/tasks/zero-shot-classification/about.md +++ b/packages/tasks/src/tasks/zero-shot-classification/about.md @@ -26,7 +26,7 @@ You can use the 🤗 Transformers library zero-shot-classification pipeline to i ```python from transformers import pipeline -pipe = pipeline(model="facebook/bart-large-mnli") +pipe = pipeline(task="zero-shot-classification", model="facebook/bart-large-mnli") pipe("I have a problem with my iphone that needs to be resolved asap!", candidate_labels=["urgent", "not urgent", "phone", "tablet", "computer"], ) diff --git a/packages/tasks/src/tasks/zero-shot-image-classification/about.md b/packages/tasks/src/tasks/zero-shot-image-classification/about.md index 8fd02c9362..94330c471e 100644 --- a/packages/tasks/src/tasks/zero-shot-image-classification/about.md +++ b/packages/tasks/src/tasks/zero-shot-image-classification/about.md @@ -32,8 +32,8 @@ The model can be loaded with the zero-shot-image-classification pipeline like so from transformers import pipeline # More models in the model hub. model_name = "openai/clip-vit-large-patch14-336" -device_name = 0 -classifier = pipeline("zero-shot-image-classification", model = model_name, device = device_name) +device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') +classifier = pipeline(task="zero-shot-image-classification", model=model_name, device=device) ``` You can then use this pipeline to classify images into any of the class names you specify. You can specify more than two class labels too. diff --git a/packages/tasks/src/tasks/zero-shot-object-detection/about.md b/packages/tasks/src/tasks/zero-shot-object-detection/about.md index d36db77398..4c67e48474 100644 --- a/packages/tasks/src/tasks/zero-shot-object-detection/about.md +++ b/packages/tasks/src/tasks/zero-shot-object-detection/about.md @@ -18,7 +18,7 @@ from PIL import Image image = Image.open("my-image.png").convert("RGB") -detector = pipeline(model="google/owlvit-base-patch32", task="zero-shot-object-detection") +detector = pipeline(task="zero-shot-object-detection", model="google/owlvit-base-patch32") predictions = detector( image, From 2ff0edab0ba38d6df04ad9695ab7353c51300e6a Mon Sep 17 00:00:00 2001 From: kadirnar Date: Mon, 18 Nov 2024 13:31:53 +0300 Subject: [PATCH 11/11] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Remove=20device?= =?UTF-8?q?=20parameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/tasks/src/tasks/image-classification/about.md | 2 +- packages/tasks/src/tasks/image-segmentation/about.md | 2 +- packages/tasks/src/tasks/object-detection/about.md | 2 +- packages/tasks/src/tasks/video-classification/about.md | 4 ++-- .../tasks/src/tasks/zero-shot-image-classification/about.md | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/tasks/src/tasks/image-classification/about.md b/packages/tasks/src/tasks/image-classification/about.md index c5a9a3f3fe..4d6f09f8ea 100644 --- a/packages/tasks/src/tasks/image-classification/about.md +++ b/packages/tasks/src/tasks/image-classification/about.md @@ -16,7 +16,7 @@ With the `transformers` library, you can use the `image-classification` pipeline ```python from transformers import pipeline -image_classifier = pipeline(task="image-classification", model="microsoft/resnet-50", device=0) +image_classifier = pipeline(task="image-classification", model="microsoft/resnet-50") result = image_classifier(IMAGE_PATH) result diff --git a/packages/tasks/src/tasks/image-segmentation/about.md b/packages/tasks/src/tasks/image-segmentation/about.md index 7a7b6fe67f..3d45d7b4e7 100644 --- a/packages/tasks/src/tasks/image-segmentation/about.md +++ b/packages/tasks/src/tasks/image-segmentation/about.md @@ -37,7 +37,7 @@ You can infer with Image Segmentation models using the `image-segmentation` pipe ```python from transformers import pipeline -model = pipeline(task="image-segmentation", model="facebook/detr-resnet-50-panoptic", device=0) +model = pipeline(task="image-segmentation", model="facebook/detr-resnet-50-panoptic") result = model(IMAGE_PATH) result diff --git a/packages/tasks/src/tasks/object-detection/about.md b/packages/tasks/src/tasks/object-detection/about.md index f959d99d39..4484f8ad5f 100644 --- a/packages/tasks/src/tasks/object-detection/about.md +++ b/packages/tasks/src/tasks/object-detection/about.md @@ -21,7 +21,7 @@ Object Detection models are used to count instances of objects in a given image, You can infer with Object Detection models through the `object-detection` pipeline. When calling the pipeline you just need to specify a path or http link to an image. ```python -model = pipeline(task="object-detection", model="facebook/detr-resnet-50", device=0) +model = pipeline(task="object-detection", model="facebook/detr-resnet-50") result = model(IMAGE_PATH) result diff --git a/packages/tasks/src/tasks/video-classification/about.md b/packages/tasks/src/tasks/video-classification/about.md index 8d74906105..45f6179953 100644 --- a/packages/tasks/src/tasks/video-classification/about.md +++ b/packages/tasks/src/tasks/video-classification/about.md @@ -17,8 +17,8 @@ Below you can find code for inferring with a pre-trained video classification mo ```python from transformers import pipeline -pipe = pipeline(task="video-classification", model="nateraw/videomae-base-finetuned-ucf101-subset", device=0) -pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/basketball.avi?download=true") +pipe = pipeline(task="video-classification", model="nateraw/videomae-base-finetuned-ucf101-subset") +pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/basketball.avi") #[{'score': 0.90, 'label': 'BasketballDunk'}, # {'score': 0.02, 'label': 'BalanceBeam'}, diff --git a/packages/tasks/src/tasks/zero-shot-image-classification/about.md b/packages/tasks/src/tasks/zero-shot-image-classification/about.md index 18635c3278..ae0c514e96 100644 --- a/packages/tasks/src/tasks/zero-shot-image-classification/about.md +++ b/packages/tasks/src/tasks/zero-shot-image-classification/about.md @@ -32,8 +32,7 @@ The model can be loaded with the zero-shot-image-classification pipeline like so from transformers import pipeline # More models in the model hub. model_name = "openai/clip-vit-large-patch14-336" -device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') -classifier = pipeline(task="zero-shot-image-classification", model=model_name, device=device) +classifier = pipeline(task="zero-shot-image-classification", model=model_name) ``` You can then use this pipeline to classify images into any of the class names you specify. You can specify more than two class labels too.