inference icon indicating copy to clipboard operation
inference copied to clipboard

openai 访问 xinference got-ocr2模型 api接口出现openai.InternalServerError: Error code: 500 - {'detail': "[address=0.0.0.0:43157, pid=78] 'GotOCR2Model' object has no attribute 'model_spec'"}

Open pandaominggz opened this issue 2 years ago • 2 comments

System Info / 系統信息

操作系统:win10, python:3.10.15,openai: 1.55.2, xinference 服务器: ubuntu22.04.5

Running Xinference with Docker? / 是否使用 Docker 运行 Xinfernece?

  • [X] docker / docker
  • [ ] pip install / 通过 pip install 安装
  • [ ] installation from source / 从源码安装

Version info / 版本信息

0.16.3

The command used to start Xinference / 用以启动 xinference 的命令

docker run -itd --name xinference -p 9998:9997 --gpus all registry.cn-hangzhou.aliyuncs.com/xprobe_xinference/xinference:latest xinference-local -H 0.0.0.0 --log-level debug

Reproduction / 复现过程

1.打开 xinference launching界面,launching got-ocr2模型, 从modelscope 下载 2.xinference running model 界面, got-ocr2 模型已经在running 3. xinference服务器 执行 nvidia-smi 显示模型已加载 4. 在win10 使用openai 库访问 xinference api ,出现错误openai.InternalServerError: Error code: 500 - {'detail': "[address=0.0.0.0:43157, pid=78] 'GotOCR2Model' object has no attribute 'model_spec'"} 5. 访问代码如下: import openai import base64

Function to encode the image

def encode_image(image_path): with open(image_path, "rb") as image_file: return base64.b64encode(image_file.read()).decode('utf-8')

Path to your image

image_path = r"D:\projects\table_rec\layout_result_cleaned\LUNA2000-200KTL-H0\1_0_table.png"

Getting the base64 string

b64_img = encode_image(image_path)

client = openai.Client( api_key="cannot be empty", base_url=f"http://10.83.172.92:9997/v1" ) response = client.chat.completions.create( model="GOT-OCR2", messages=[ { "role": "user", "content": [ {"type": "text", "text": "What’s in this image?"}, { "type": "image_url", "image_url": { "url": f"data:image/jpeg;base64,{b64_img}", }, }, ], } ], ) print(response.choices[0])

Expected behavior / 期待表现

正常输出模型ocr结果

pandaominggz avatar Nov 29 '24 05:11 pandaominggz

GOT-OCR 是一个 OCR 模型,不能用来聊天。

qinxuye avatar Nov 29 '24 09:11 qinxuye

在xinference 如何通过API调用呢?

pandaominggz avatar Dec 02 '24 05:12 pandaominggz