Skip to content

Commit 2eda42a

Browse files
committed
fix: image segmentation on hf inference
Signed-off-by: Raphael Glon <[email protected]>
1 parent 088cad0 commit 2eda42a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/huggingface_inference_toolkit/handler.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,14 @@ def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]:
152152
else:
153153
logging.logger.warning("Output unexpected type %s", type(resp))
154154
return resp
155-
155+
if self.pipeline.task == "image-segmentation":
156+
if isinstance(resp, list):
157+
new_resp = []
158+
for el in resp:
159+
if isinstance(el, dict) and el.get("score") is None:
160+
el["score"] = 1
161+
new_resp.append(el)
162+
resp = new_resp
156163
return resp
157164

158165

0 commit comments

Comments
 (0)