Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
@@ -8,15 +8,13 @@ import io
|
|
8 |
def answer(input_img, selected):
|
9 |
|
10 |
buffer = io.BytesIO()
|
11 |
-
|
12 |
input_img.save(buffer, format="PNG")
|
13 |
image_data = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
else:
|
18 |
-
model_input = os.environ['PROMPT_OCR']
|
19 |
|
20 |
-
|
|
|
21 |
|
22 |
return respose
|
|
|
8 |
def answer(input_img, selected):
|
9 |
|
10 |
buffer = io.BytesIO()
|
|
|
11 |
input_img.save(buffer, format="PNG")
|
12 |
image_data = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
13 |
|
14 |
+
# Xác định model_input dựa trên tùy chọn của người dùng
|
15 |
+
model_input = os.environ['PROMPT'] if selected == "Describe things" else os.environ['PROMPT_OCR']
|
|
|
|
|
16 |
|
17 |
+
# Thực thi mô hình với hình ảnh đã mã hóa và đầu vào mô hình
|
18 |
+
response = executor.execute_with_image(user_input='', model_input=model_input, base64_image=image_data)
|
19 |
|
20 |
return respose
|