This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
importfastdeployasfd
importos.pathasop
defbuild_option(device,backend,cache_file):
"""
创建Runtime运行选项
device:设备CPU or GPU
backend:TensorRT引擎
"""
option=fd.RuntimeOption()
option.use_cpu()
option.trt_option.serialize_file=cache_file
ifdevice.lower()=="gpu":
option.use_gpu(0)
ifbackend.lower()=="trt":
assertdevice.lower(
)=="gpu","TensorRT backend require inference on device GPU."