Wang Tao

Results 2 comments of Wang Tao

我试过像REST API那样把图像的base64码放在message列表传给模型,但是模型识别不了该图像,而是回答我传了一串符号或者公式;此外,我还试过把图片路径直接放到message列表传递,但模型回答热仍然是错误的。目前,我只在cmd下使用模型正确识别到了图片,所以我怀疑ollama-python库还没有这个功能.

# python实现REST API请求传递图片给大模型,亲测可行 # 请求的URL url = "http://localhost:11434/api/generate" # 图像路径 image_path = r'D:\用户\智学伴\demo4.png' # 将图像转换为Base64编码 def image_to_base64(image_path): image = Image.open(image_path) buffered = BytesIO() image.save(buffered, format="JPEG") return base64.b64encode(buffered.getvalue()).decode() # 获取图像的Base64编码 base64_string...