File size: 472 Bytes
63f6e61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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']