MCPcopy Create free account
hub / github.com/OpenBMB/BMTools / visual_question_answering

Function visual_question_answering

bmtools/tools/hugging_tools/api.py:180–184  ·  view source on GitHub ↗
(model_id: str, image_file_name: str, text: str)

Source from the content-addressed store, hash-verified

178 # CV tasks
179 @task
180 def visual_question_answering(model_id: str, image_file_name: str, text: str) -> str:
181 inference = InferenceApi(repo_id=model_id, token=CONFIG["huggingface"]["token"])
182 img_data = image_to_bytes(f"{DIRPATH}/{INPUT_PATH}/{image_file_name}")
183 img_base64 = base64.b64encode(img_data).decode("utf-8")
184 return str(inference({"question": text, "image": img_base64}))
185 @task
186 def document_question_answering(model_id: str, image_file_name: str, text: str) -> str:
187 inference = InferenceApi(repo_id=model_id, token=CONFIG["huggingface"]["token"])

Callers

nothing calls this directly

Calls 1

image_to_bytesFunction · 0.85

Tested by

no test coverage detected