oscarfu0501 commited on
Commit
f542585
·
verified ·
1 Parent(s): fef199d

Update imageBase64

Browse files
Files changed (1) hide show
  1. handler.py +13 -4
handler.py CHANGED
@@ -18,12 +18,21 @@ class EndpointHandler():
18
  # inputs = self.processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True)
19
  # logits_per_image = outputs.logits_per_image # this is the image-text similarity score
20
  # probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
21
-
 
 
 
 
 
 
 
 
22
  inputs = data.get("inputs")
 
23
  text = inputs.get("text")
24
- imageData = inputs.get("image")
25
- url = inputs.get("image")
26
- image = Image.open(requests.get(url, stream=True).raw)
27
  # image = Image.open(BytesIO(base64.b64decode(imageData)))
28
  inputs = self.processor(text=text, images=image, return_tensors="pt", padding=True)
29
  outputs = self.model(**inputs)
 
18
  # inputs = self.processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True)
19
  # logits_per_image = outputs.logits_per_image # this is the image-text similarity score
20
  # probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
21
+ # print(probs)
22
+
23
+ # data = {
24
+ # "inputs": {
25
+ # "image": "http://images.cocodataset.org/val2017/000000039769.jpg",
26
+ # "text": ["a photo of a cat", "a photo of a dog"]
27
+ # },
28
+ # }
29
+
30
  inputs = data.get("inputs")
31
+ imageURL = inputs.get("image")
32
  text = inputs.get("text")
33
+ print(imageURL)
34
+ print(text)
35
+ image = Image.open(requests.get(imageURL, stream=True).raw)
36
  # image = Image.open(BytesIO(base64.b64decode(imageData)))
37
  inputs = self.processor(text=text, images=image, return_tensors="pt", padding=True)
38
  outputs = self.model(**inputs)