fashxp commited on
Commit
6617b85
1 Parent(s): d793007
Files changed (2) hide show
  1. README.md +25 -0
  2. handler.py +0 -5
README.md ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - vision
4
+ - zero-shot-image-classification
5
+ - endpoints-template
6
+ library_name: generic
7
+ ---
8
+
9
+ # Fork of [openai/clip-vit-base-patch32](https://huggingface.co/openai/clip-vit-base-patch32) for a `zero-sho-image-classification` Inference endpoint.
10
+
11
+ This repository implements a `custom` task for `zero-shot-image-classification` for 🤗 Inference Endpoints. The code for the customized
12
+ pipeline is in the handler.py.
13
+
14
+ To use deploy this model an Inference Endpoint you have to select `Custom` as task to use the `handler.py` file.
15
+
16
+ ### expected Request payload
17
+
18
+ ```json
19
+ {
20
+ "image": encoded_image,
21
+ "parameters": {
22
+ "candidate_labels": "green, yellow, blue, white, silver"
23
+ }
24
+ }
25
+ ```
handler.py CHANGED
@@ -17,17 +17,12 @@ class EndpointHandler():
17
  Return:
18
  A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
19
  """
20
- #inputs = data.pop("inputs", data)
21
- #image_data = inputs['image']
22
-
23
  image_data = data.pop("image", data)
24
  # decode base64 image to PIL
25
  image = Image.open(BytesIO(base64.b64decode(image_data)))
26
 
27
  parameters = data.pop("parameters", data)
28
- #parameters = inputs['parameters']
29
  candidate_labels = parameters['candidate_labels']
30
- print(candidate_labels)
31
 
32
  candidate_labels_array = list(map(str.strip, candidate_labels.split(',')))
33
 
 
17
  Return:
18
  A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
19
  """
 
 
 
20
  image_data = data.pop("image", data)
21
  # decode base64 image to PIL
22
  image = Image.open(BytesIO(base64.b64decode(image_data)))
23
 
24
  parameters = data.pop("parameters", data)
 
25
  candidate_labels = parameters['candidate_labels']
 
26
 
27
  candidate_labels_array = list(map(str.strip, candidate_labels.split(',')))
28