File size: 706 Bytes
ad17f03
 
 
 
 
 
 
d3f8c04
be2e555
27b67fd
 
 
ad17f03
be2e555
ad17f03
 
ae567de
 
d3f8c04
ae567de
 
ad17f03
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pkgs import QuotaManager, executor
import os
import base64
from PIL import Image
import io


def answer(input_img, selected):

    print(input_img)
    print(selected)
    
    buffer = io.BytesIO()
    input_img.save(buffer, format="PNG")
    image_data = base64.b64encode(buffer.getvalue()).decode('utf-8')

    # Xác định model_input dựa trên tùy chọn của người dùng
    model_input = os.environ['PROMPT'] if selected == "Describe things" else os.environ['PROMPT_OCR']

    # Thực thi mô hình với hình ảnh đã mã hóa và đầu vào mô hình
    response = executor.execute_with_image(user_input='', model_input=model_input, base64_image=image_data)

    return respose