Update handler.py
Browse files- handler.py +4 -4
handler.py
CHANGED
@@ -18,17 +18,17 @@ class EndpointHandler():
|
|
18 |
Return:
|
19 |
A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
|
20 |
"""
|
21 |
-
|
22 |
|
23 |
# decode base64 image to PIL
|
24 |
-
image = Image.open(BytesIO(base64.b64decode(
|
25 |
|
26 |
# run prediction one image wit provided candiates
|
27 |
-
inputs = self.processor(image, text=
|
28 |
outputs = self.model(**inputs)
|
29 |
results = self.processor.post_process_grounded_object_detection(
|
30 |
outputs,
|
31 |
-
classes=
|
32 |
target_sizes=[image.size[::-1]],
|
33 |
score_threshold=0.3,
|
34 |
nms_threshold=0.3,
|
|
|
18 |
Return:
|
19 |
A :obj:`list`:. The list contains items that are dicts should be liked {"label": "XXX", "score": 0.82}
|
20 |
"""
|
21 |
+
inputs_request = data.pop("inputs", data)
|
22 |
|
23 |
# decode base64 image to PIL
|
24 |
+
image = Image.open(BytesIO(base64.b64decode(inputs_request['image'])))
|
25 |
|
26 |
# run prediction one image wit provided candiates
|
27 |
+
inputs = self.processor(image, text=inputs_request["candidates"], return_tensors="pt")
|
28 |
outputs = self.model(**inputs)
|
29 |
results = self.processor.post_process_grounded_object_detection(
|
30 |
outputs,
|
31 |
+
classes=inputs_request["candidates"],
|
32 |
target_sizes=[image.size[::-1]],
|
33 |
score_threshold=0.3,
|
34 |
nms_threshold=0.3,
|