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 img2text_controller(image: Image, fw_option: str = 'none'): | |
request_data_files = { | |
"image": image_to_bytes(image), | |
} | |
response = post_data( | |
f"/api/img2text/{get_fw_query_params(fw_option)}", files=request_data_files) | |
if response is None: | |
return None | |
return response['caption'] | |