Skip to content

paddleServing部署电表检测模型,不确定预期输出 #1974

Closed
@gubinjie

Description

@gubinjie

1、前期模型训练按照下面的项目方式进行:

https://aistudio.baidu.com/projectdetail/3429765?channelType=0&channel=0

2、通过PaddleOCR导出模型

python tools/export_model.py -c ./configs/det/ch_PP-OCRv3/ch_PP-OCRv3_det_student.yml -o Global.pretrained_model=./output/dianbiao_ch_PP-OCR_V3_det/best_accuracy Global.save_inference_dir=./inference/det_db

3、模型转换成serving可以识别的

python -m paddle_serving_client.convert --dirname ./det_db/ --model_filename inference.pdmodel --params_filename inference.pdiparams --serving_server ./ppocr_det_v3_serving/ --serving_client ./ppocr_det_v3_client/

4、启动模型Serving服务

python3 -m paddle_serving_server.serve --model /opt/ammeter_identify_mode/ppocr_det_v3_serving/ --port 9812

5、配置文件serving_client_conf.prototxt

` feed_var {

name: "x"
alias_name: "x"
is_lod_tensor: false
feed_type: 1
shape: 3
}
fetch_var {
name: "sigmoid_0.tmp_0"
alias_name: "sigmoid_0.tmp_0"
is_lod_tensor: false
fetch_type: 1
shape: 1
}`

6、客户端调用代码:

` from paddle_serving_app.reader import *

from paddle_serving_client import Client
import cv2, json, datetime, os,numpy as np
import numpy as np

parent_directory = os.path.dirname(os.path.abspath(file))

client = Client()
#client.load_client_config(os.path.join(parent_directory, 'serving_client_conf.prototxt'))
client.load_client_config('./serving_det_client_conf.prototxt')
client.connect(['****:9812'])

preprocess = Sequential([
File2Image(), BGR2RGB(),
Resize(
(960, 960), interpolation=cv2.INTER_LANCZOS4), Div(255.0),Transpose((2, 0, 1))
])

im = preprocess('./P23030907100210.jpg')

fetch_map = client.predict(
feed={
"x": im,
},
fetch=["sigmoid_0.tmp_0"],
batch=False)

detections = fetch_map["sigmoid_0.tmp_0"]`

输出:

print(fetch_map)
{'sigmoid_0.tmp_0': array([[[[6.7720975e-08, 1.3140065e-07, 1.9094442e-08, ...,
2.3576363e-09, 7.7910184e-10, 4.4165565e-09],
[6.3383972e-08, 1.4166790e-07, 3.6551061e-08, ...,
4.6193835e-09, 1.3099265e-09, 4.5741602e-09],
[2.5273311e-08, 1.4597879e-07, 3.7196685e-08, ...,
6.0767689e-09, 7.5343232e-10, 1.7367194e-08],
...,
[4.4501288e-08, 3.6136807e-08, 7.8183229e-09, ...,
5.6374336e-08, 1.7245652e-08, 2.9781738e-08],
[1.5184209e-08, 7.0195000e-08, 1.4452498e-08, ...,
5.4933416e-08, 9.6213251e-09, 1.3786045e-07],
[7.2296395e-08, 3.9937358e-08, 2.8997006e-08, ...,
1.5954635e-07, 4.4072682e-08, 2.0925140e-07]]]], dtype=float32)}

我疑问的是这个结果是否正确?这个检测模型为什么没有告诉我检测的四点坐标?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions