Instructions to use aayushgs/clip-vit-large-patch14-custom-handler with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aayushgs/clip-vit-large-patch14-custom-handler with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-image-classification", model="aayushgs/clip-vit-large-patch14-custom-handler") pipe( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png", candidate_labels=["animals", "humans", "landscape"], )# Load model directly from transformers import AutoProcessor, AutoModelForZeroShotImageClassification processor = AutoProcessor.from_pretrained("aayushgs/clip-vit-large-patch14-custom-handler") model = AutoModelForZeroShotImageClassification.from_pretrained("aayushgs/clip-vit-large-patch14-custom-handler") - Notebooks
- Google Colab
- Kaggle
fix typo
Browse files- handler.py +3 -3
handler.py
CHANGED
|
@@ -13,7 +13,7 @@ class EndpointHandler():
|
|
| 13 |
"""
|
| 14 |
data args:
|
| 15 |
images (:obj:`string`)
|
| 16 |
-
|
| 17 |
Return:
|
| 18 |
A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
|
| 19 |
"""
|
|
@@ -22,6 +22,6 @@ class EndpointHandler():
|
|
| 22 |
# decode base64 image to PIL
|
| 23 |
image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
|
| 24 |
|
| 25 |
-
# run prediction one image wit provided
|
| 26 |
-
prediction = self.pipeline(images=[image], candidate_labels=inputs["
|
| 27 |
return prediction[0]
|
|
|
|
| 13 |
"""
|
| 14 |
data args:
|
| 15 |
images (:obj:`string`)
|
| 16 |
+
candidates (:obj:`list`)
|
| 17 |
Return:
|
| 18 |
A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
|
| 19 |
"""
|
|
|
|
| 22 |
# decode base64 image to PIL
|
| 23 |
image = Image.open(BytesIO(base64.b64decode(inputs['image'])))
|
| 24 |
|
| 25 |
+
# run prediction one image wit provided candidates
|
| 26 |
+
prediction = self.pipeline(images=[image], candidate_labels=inputs["candidates"])
|
| 27 |
return prediction[0]
|