标准化API服务(免费版)
使用流程
使用流程
更新版本
将AI测试平台更新到 2025.3.1 以上的版本:
加载模型
调用API
import base64
import json
import requests
session = requests.session()
url = 'http://127.0.0.1:9890/api/inference'
model_path = r"C:\Users\Administrator\Desktop\测试模型\手机屏幕缺陷检测_20241010_173458.dvp"
img_path = r"C:\Users\Administrator\Desktop\测试模型\Scr_0049.jpg"
print(f'推理图片:{img_path}')
with open(img_path, 'rb') as f:
img_base64 = base64.b64encode(f.read()).decode()
data = {'model_path': model_path, 'img': img_base64}
response = session.post(url, json=data)
result = response.json()
print(json.dumps(result, indent=2, ensure_ascii=False))
返回结果
{
"code": "00000",
"task_type": "实例分割",
"results": [
{
"area": 181,
"bbox": [
386.8935241699219,
132.375244140625,
565.6471557617188,
169.44708251953125
],
"category_id": 0,
"category_name": "划痕",
"score": 0.9990857839584351,
"with_mask": true
}
]
}