|
|
3 weeks ago | |
|---|---|---|
| .. | ||
| agent | 2 months ago | |
| api | 2 months ago | |
| config | 2 months ago | |
| icon | 2 months ago | |
| README.md | 2 months ago | |
| ocr_config.yaml | 3 weeks ago | |
| ocr_config_compress.yaml | 3 weeks ago | |
| requirements_ocr.txt | 2 months ago | |
| start.py | 3 weeks ago | |
基于大模型的化学品安全标签信息提取服务。
ocr/
├── agent/ # OCR Agent 核心逻辑(.pyc)
├── api/ # FastAPI 服务入口(.pyc)
├── config/ # 配置模块(.pyc)
├── icon/ # GHS 危险象形图(GHS01~GHS09.png)
├── ocr_config.yaml # 服务配置文件
├── start.py # 启动脚本
└── requirements_ocr.txt
pip install -r requirements_ocr.txt
编辑 ocr_config.yaml,按实际环境修改以下参数:
inference:
url: "http://<推理服务地址>/v1/chat/completions"
auth_token: "Bearer <your_token>"
model: "<模型名称>"
server:
host: "0.0.0.0"
port: 6006
max_concurrent: 5
| 参数 | 说明 |
|---|---|
inference.url |
推理服务的请求地址 |
inference.auth_token |
鉴权 Token,格式为 Bearer <token> |
inference.model |
调用的模型名称 |
server.host |
API 服务监听地址,0.0.0.0 允许外部访问 |
server.port |
API 服务监听端口 |
server.max_concurrent |
最大并发请求数 |
# 使用默认配置文件 ocr_config.yaml
python start.py
# 指定配置文件
python start.py --config /path/to/your_config.yaml
服务启动后访问 http://<host>:<port>/docs 查看接口文档。
/api/v1/agent_ocr提取化学品安全标签信息。
请求体
{
"image": "<base64 编码的图像字符串>"
}
成功响应
{
"code": "200",
"message": "操作成功",
"data": {
"tag": {
"name_cn": "化学品中文名称",
"name_en": "化学品英文名称",
"cf_list": [
{
"cas_name": "成分名称",
"cas_cf": "化学式",
"true_rate": "实际浓度",
"rate": "浓度区间",
"cas_no": "CAS号"
}
]
},
"tag_images": ["GHS02", "GHS07"],
"key_word": "警告",
"risk_notice": "危险性说明",
"pre_notice": {
"pre_method": "预防措施",
"acc_response": "事故响应",
"safe_keep": "安全存储",
"abandon_deal": "废弃处置"
},
"supplier": [
{
"name": "供应商名称",
"address": "供应商地址",
"tel": "供应商电话",
"post": "供应商邮编"
}
],
"acc_tel": "应急咨询电话"
}
}
失败响应
{
"code": "500",
"message": "请求失败",
"data": {}
}
/health健康检查,返回服务状态及当前并发数。