未验证 提交 3ceb2234 编写于 作者: littletomatodonkey's avatar littletomatodonkey 提交者: GitHub

polish dir name (#5407)

上级 e916250a
...@@ -5,9 +5,11 @@ import cv2 ...@@ -5,9 +5,11 @@ import cv2
import base64 import base64
import os import os
def cv2_to_base64(image): def cv2_to_base64(image):
return base64.b64encode(image).decode('utf8') return base64.b64encode(image).decode('utf8')
if __name__ == "__main__": if __name__ == "__main__":
url = "http://127.0.0.1:18080/tipc_example/prediction" url = "http://127.0.0.1:18080/tipc_example/prediction"
logid = 10000 logid = 10000
...@@ -15,7 +17,7 @@ if __name__ == "__main__": ...@@ -15,7 +17,7 @@ if __name__ == "__main__":
with open(img_path, 'rb') as file: with open(img_path, 'rb') as file:
image_data1 = file.read() image_data1 = file.read()
image = cv2_to_base64(image_data1) image = cv2_to_base64(image_data1)
data = {"key": ["image"], "value": [image], "logid":logid} data = {"key": ["image"], "value": [image], "logid": logid}
for i in range(5): for i in range(5):
r = requests.post(url=url, data=json.dumps(data)) r = requests.post(url=url, data=json.dumps(data))
print(r.json()) print(r.json())
...@@ -14,22 +14,25 @@ ...@@ -14,22 +14,25 @@
from paddle_serving_server.web_service import WebService, Op from paddle_serving_server.web_service import WebService, Op
class TIPCExampleOp(Op): class TIPCExampleOp(Op):
def init_op(self): def init_op(self):
pass pass
def preprocess(self, input_dicts, data_id, log_id): def preprocess(self, input_dicts, data_id, log_id):
pass pass
def postprocess(self, input_dicts, fetch_dict, data_id, log_id): def postprocess(self, input_dicts, fetch_dict, data_id, log_id):
pass pass
class TIPCExampleService(WebService): class TIPCExampleService(WebService):
def get_pipeline_response(self, read_op): def get_pipeline_response(self, read_op):
tipc_example_op = TIPCExampleOp(name="tipc_example", input_ops=[read_op]) tipc_example_op = TIPCExampleOp(
name="tipc_example", input_ops=[read_op])
return tipc_example_op return tipc_example_op
uci_service = TIPCExampleService(name="tipc_example") uci_service = TIPCExampleService(name="tipc_example")
uci_service.prepare_pipeline_config("config.yml") uci_service.prepare_pipeline_config("config.yml")
uci_service.run_service() uci_service.run_service()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册