Devops-hestabit commited on
Commit
c382948
·
verified ·
1 Parent(s): 6c72430

Add inputs json format

Browse files
Files changed (1) hide show
  1. handler.py +11 -11
handler.py CHANGED
@@ -17,15 +17,15 @@ class EndpointHandler():
17
  Return:
18
  A :obj:`list` | `dict`: will be serialized and returned
19
  """
20
- try:
21
- image_url = data.get('image_url', "")
22
- prompt = data.get("prompt", "")
23
- if not image_url:
24
- return {'error': 'No image URL provided'}
 
25
 
26
- image = load_image(image_url)
27
-
28
- response = self.pipe((prompt, image))
29
- return {'response': response.text}
30
- except Exception as err:
31
- return {"error", str(err)}
 
17
  Return:
18
  A :obj:`list` | `dict`: will be serialized and returned
19
  """
20
+ inputs = data.pop("inputs", data)
21
+ image_url = inputs.get("image_url")
22
+ prompt = inputs.get("prompt")
23
+
24
+ if not image_url:
25
+ return [{'error': 'No image URL provided'}]
26
 
27
+ image = load_image(image_url)
28
+
29
+
30
+ response = self.pipe((prompt, image))
31
+ return {'response': response.text}