updates
Browse filesFiles changed (2)
- README.mdAdded+25
- handler.py-5
12345678910111213141516171819202122232425---tags:- vision- zero-shot-image-classification- endpoints-templatelibrary_name: generic---
# Fork of [openai/clip-vit-base-patch32](https://huggingface.co/openai/clip-vit-base-patch32) for a `zero-sho-image-classification` Inference endpoint.
This repository implements a `custom` task for `zero-shot-image-classification` for 🤗 Inference Endpoints. The code for the customized pipeline is in the handler.py.
To use deploy this model an Inference Endpoint you have to select `Custom` as task to use the `handler.py` file.
### expected Request payload
```json{ "image": encoded_image, "parameters": { "candidate_labels": "green, yellow, blue, white, silver" }}```16 unmodified lines171819202122232425262728293031323316 unmodified linesReturn:A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}"""#inputs = data.pop("inputs", data)#image_data = inputs['image']image_data = data.pop("image", data)# decode base64 image to PILimage = Image.open(BytesIO(base64.b64decode(image_data)))parameters = data.pop("parameters", data)#parameters = inputs['parameters']candidate_labels = parameters['candidate_labels']print(candidate_labels)candidate_labels_array = list(map(str.strip, candidate_labels.split(',')))16 unmodified lines17181920212223242526272816 unmodified linesReturn:A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}"""image_data = data.pop("image", data)# decode base64 image to PILimage = Image.open(BytesIO(base64.b64decode(image_data)))parameters = data.pop("parameters", data)candidate_labels = parameters['candidate_labels']candidate_labels_array = list(map(str.strip, candidate_labels.split(',')))
README.mdAdded+25
handler.py-5