qwenvl/app/test.py
2024-11-12 16:39:19 +08:00

30 lines
663 B
Python

import requests
import base64
def file2b64(file_path):
# 读取文件内容
with open(file_path, 'rb') as file:
file_content = file.read()
# 将文件内容转换为Base64编码
base64_encoded_data = base64.b64encode(file_content)
# 将Base64编码的数据转换为字符串
base64_encoded_str = base64_encoded_data.decode('utf-8')
return base64_encoded_str
while True:
print('prompt:')
p = input()
print('input image path:')
i = input()
if p == '' or i == '':
continue
ret = requests.get('http://pd4e.com:10090/api',
params={
'prompt':p,
'image':file2b64(i)
})
print(ret.text)