Spaces:
Sleeping
Sleeping
from pkgs import QuotaManager, executor | |
import os | |
import base64 | |
from PIL import Image | |
import io | |
def answer(selected, input_img): | |
# 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 response |