[Serving] Simple serving YOLOv5 and PP-OCRv3 example, add uvicorn to fastdeploy tools (#986)

* ppocrv3 simple serving

* add uvicorn to fd tools

* update ppdet simple serving readme

* yolov5 simple serving

* not import simple serving by default

* remove config from envs

* update comment
This commit is contained in:
Wang Xinyu
2022-12-28 10:03:42 +08:00
committed by GitHub
parent 0ead9d27c2
commit aea454a856
18 changed files with 364 additions and 42 deletions

View File

@@ -0,0 +1,38 @@
import fastdeploy as fd
from fastdeploy.serving.server import SimpleServer
import os
import logging
logging.getLogger().setLevel(logging.INFO)
# Configurations
model_dir = 'yolov5s_infer'
device = 'cpu'
use_trt = False
# Prepare model
model_file = os.path.join(model_dir, "model.pdmodel")
params_file = os.path.join(model_dir, "model.pdiparams")
# Setup runtime option to select hardware, backend, etc.
option = fd.RuntimeOption()
if device.lower() == 'gpu':
option.use_gpu()
if use_trt:
option.use_trt_backend()
option.set_trt_input_shape("images", [1, 3, 640, 640])
option.set_trt_cache_file('yolov5s.trt')
# Create model instance
model_instance = fd.vision.detection.YOLOv5(
model_file,
params_file,
runtime_option=option,
model_format=fd.ModelFormat.PADDLE)
# Create server, setup REST API
app = SimpleServer()
app.register(
task_name="fd/yolov5s",
model_handler=fd.serving.handler.VisionModelHandler,
predictor=model_instance)