alvarobartt HF staff commited on
Commit
56e1504
·
verified ·
1 Parent(s): baebe6f

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -3
handler.py CHANGED
@@ -31,9 +31,12 @@ class EndpointHandler:
31
 
32
  predictions = []
33
  for input in data["instances"]:
34
- if any(key not in input for key in {"prompt", "image_url"}):
 
 
 
35
  raise ValueError(
36
- "The request body for each instance should contain both the `prompt` and the `image_url` key with a valid image URL."
37
  )
38
 
39
  try:
@@ -44,7 +47,7 @@ class EndpointHandler:
44
  )
45
 
46
  inputs = self.processor(
47
- text=input["prompt"], images=image, return_tensors="pt"
48
  ).to(self.model.device)
49
  input_len = inputs["input_ids"].shape[-1]
50
 
 
31
 
32
  predictions = []
33
  for input in data["instances"]:
34
+ if "prompt" in input:
35
+ input["text"] = input.pop("prompt")
36
+
37
+ if any(key not in input for key in {"text", "image_url"}):
38
  raise ValueError(
39
+ "The request body for each instance should contain both the `text` and the `image_url` key with a valid image URL."
40
  )
41
 
42
  try:
 
47
  )
48
 
49
  inputs = self.processor(
50
+ text=input["text"], images=image, return_tensors="pt"
51
  ).to(self.model.device)
52
  input_len = inputs["input_ids"].shape[-1]
53