Spaces:
Runtime error
Runtime error
from PIL import Image | |
from controllers.utils import image_to_bytes | |
from services.api_service import post_data | |
from .fw import get_fw_query_params | |
def vqa_controller(image: Image, question: str, fw_option: str = 'none'): | |
request_data_files = { | |
"image": image_to_bytes(image), | |
} | |
request_data_form = { | |
"question": question, | |
} | |
response = post_data( | |
f"/api/vqa/{get_fw_query_params(fw_option)}", files=request_data_files, data=request_data_form) | |
if response is None: | |
return None | |
return response['answer'] | |