mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
Rename fastdeploy_runtime.h to runtime.h and Frontend to ModelFormat (#263)
rename frontend to model_format
This commit is contained in:
@@ -16,7 +16,7 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from .c_lib_wrap import (Frontend, Backend, FDDataType, TensorInfo, Device,
|
||||
from .c_lib_wrap import (ModelFormat, Backend, FDDataType, TensorInfo, Device,
|
||||
FDTensor, is_built_with_gpu, is_built_with_ort,
|
||||
is_built_with_paddle, is_built_with_trt,
|
||||
get_default_cuda_directory)
|
||||
|
@@ -15,7 +15,7 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
from ... import Frontend
|
||||
from ... import ModelFormat
|
||||
from ... import RuntimeOption
|
||||
from ... import c_lib_wrap as C
|
||||
|
||||
@@ -47,7 +47,7 @@ class UIEModel(object):
|
||||
max_length=128,
|
||||
schema=[],
|
||||
runtime_option=RuntimeOption(),
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
if isinstance(schema, list):
|
||||
schema = SchemaNode("", schema)._schema_node_children
|
||||
elif isinstance(schema, dict):
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ class PaddleClasModel(FastDeployModel):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PaddleClasModel, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "PaddleClasModel only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "PaddleClasModel only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.classification.PaddleClasModel(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class NanoDetPlus(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(NanoDetPlus, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class ScaledYOLOv4(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(ScaledYOLOv4, self).__init__(runtime_option)
|
||||
@@ -92,21 +92,19 @@ class ScaledYOLOv4(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
||||
@max_wh.setter
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOR(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOR, self).__init__(runtime_option)
|
||||
@@ -92,21 +92,19 @@ class YOLOR(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
||||
@max_wh.setter
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOv5(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOv5, self).__init__(runtime_option)
|
||||
@@ -121,21 +121,19 @@ class YOLOv5(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
||||
@max_wh.setter
|
||||
@@ -147,6 +145,5 @@ class YOLOv5(FastDeployModel):
|
||||
@multi_label.setter
|
||||
def multi_label(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `multi_label` must be type of bool."
|
||||
value, bool), "The value to set `multi_label` must be type of bool."
|
||||
self._model.multi_label = value
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOv5Lite(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOv5Lite, self).__init__(runtime_option)
|
||||
@@ -100,21 +100,19 @@ class YOLOv5Lite(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
||||
@max_wh.setter
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOv6(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOv6, self).__init__(runtime_option)
|
||||
@@ -92,21 +92,19 @@ class YOLOv6(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
||||
@max_wh.setter
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOv7(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOv7, self).__init__(runtime_option)
|
||||
@@ -92,21 +92,19 @@ class YOLOv7(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
||||
@max_wh.setter
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOv7End2EndORT(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOv7End2EndORT, self).__init__(runtime_option)
|
||||
@@ -87,19 +87,17 @@ class YOLOv7End2EndORT(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOv7End2EndTRT(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOv7End2EndTRT, self).__init__(runtime_option)
|
||||
@@ -87,19 +87,17 @@ class YOLOv7End2EndTRT(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOX(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOX, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ class PPYOLOE(FastDeployModel):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "PPYOLOE model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "PPYOLOE model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.PPYOLOE(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
@@ -44,10 +44,10 @@ class PPYOLO(PPYOLOE):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "PPYOLO model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "PPYOLO model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.PPYOLO(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
@@ -60,10 +60,10 @@ class PPYOLOv2(PPYOLOE):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "PPYOLOv2 model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "PPYOLOv2 model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.PPYOLOv2(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
@@ -76,10 +76,10 @@ class PaddleYOLOX(PPYOLOE):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "PaddleYOLOX model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "PaddleYOLOX model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.PaddleYOLOX(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
@@ -92,10 +92,10 @@ class PicoDet(PPYOLOE):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "PicoDet model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "PicoDet model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.PicoDet(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
@@ -108,10 +108,10 @@ class FasterRCNN(PPYOLOE):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "FasterRCNN model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "FasterRCNN model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.FasterRCNN(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
@@ -124,10 +124,10 @@ class YOLOv3(PPYOLOE):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "YOLOv3 model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "YOLOv3 model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.YOLOv3(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
@@ -140,10 +140,10 @@ class MaskRCNN(FastDeployModel):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(MaskRCNN, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "MaskRCNN model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "MaskRCNN model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.MaskRCNN(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class RetinaFace(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(RetinaFace, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ class SCRFD(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(SCRFD, self).__init__(runtime_option)
|
||||
|
||||
self._model = C.vision.facedet.SCRFD(
|
||||
model_file, params_file, self._runtime_option, model_format)
|
||||
self._model = C.vision.facedet.SCRFD(model_file, params_file,
|
||||
self._runtime_option, model_format)
|
||||
# 通过self.initialized判断整个模型的初始化是否成功
|
||||
assert self.initialized, "SCRFD initialize failed."
|
||||
|
||||
@@ -108,21 +108,19 @@ class SCRFD(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
||||
@downsample_strides.setter
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class UltraFace(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(UltraFace, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class YOLOv5Face(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(YOLOv5Face, self).__init__(runtime_option)
|
||||
@@ -92,21 +92,19 @@ class YOLOv5Face(FastDeployModel):
|
||||
@is_mini_pad.setter
|
||||
def is_mini_pad(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
value, bool), "The value to set `is_mini_pad` must be type of bool."
|
||||
self._model.is_mini_pad = value
|
||||
|
||||
@is_scale_up.setter
|
||||
def is_scale_up(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
bool), "The value to set `is_scale_up` must be type of bool."
|
||||
value, bool), "The value to set `is_scale_up` must be type of bool."
|
||||
self._model.is_scale_up = value
|
||||
|
||||
@stride.setter
|
||||
def stride(self, value):
|
||||
assert isinstance(
|
||||
value, int), "The value to set `stride` must be type of int."
|
||||
assert isinstance(value,
|
||||
int), "The value to set `stride` must be type of int."
|
||||
self._model.stride = value
|
||||
|
||||
@landmarks_per_face.setter
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
from ..contrib.insightface_rec import InsightFaceRecognitionModel
|
||||
|
||||
@@ -24,7 +24,7 @@ class ArcFace(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(ArcFace, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class CosFace(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(CosFace, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class InsightFaceRecognitionModel(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(InsightFaceRecognitionModel, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class PartialFC(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(PartialFC, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class VPL(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(VPL, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class MODNet(FastDeployModel):
|
||||
model_file,
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.ONNX):
|
||||
model_format=ModelFormat.ONNX):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(MODNet, self).__init__(runtime_option)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ class PPMatting(FastDeployModel):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PPMatting, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "PPMatting model only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "PPMatting model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.matting.PPMatting(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class DBDetector(FastDeployModel):
|
||||
model_file="",
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(DBDetector, self).__init__(runtime_option)
|
||||
@@ -81,8 +81,8 @@ class DBDetector(FastDeployModel):
|
||||
@det_db_box_thresh.setter
|
||||
def det_db_box_thresh(self, value):
|
||||
assert isinstance(
|
||||
value, float
|
||||
), "The value to set `det_db_box_thresh` must be type of float."
|
||||
value,
|
||||
float), "The value to set `det_db_box_thresh` must be type of float."
|
||||
self._model.det_db_box_thresh = value
|
||||
|
||||
@det_db_unclip_ratio.setter
|
||||
@@ -118,7 +118,7 @@ class Classifier(FastDeployModel):
|
||||
model_file="",
|
||||
params_file="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(Classifier, self).__init__(runtime_option)
|
||||
@@ -159,8 +159,7 @@ class Classifier(FastDeployModel):
|
||||
@cls_batch_num.setter
|
||||
def cls_batch_num(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
int), "The value to set `cls_batch_num` must be type of int."
|
||||
value, int), "The value to set `cls_batch_num` must be type of int."
|
||||
self._model.cls_batch_num = value
|
||||
|
||||
|
||||
@@ -170,7 +169,7 @@ class Recognizer(FastDeployModel):
|
||||
params_file="",
|
||||
label_path="",
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
# 调用基函数进行backend_option的初始化
|
||||
# 初始化后的option保存在self._runtime_option
|
||||
super(Recognizer, self).__init__(runtime_option)
|
||||
@@ -211,18 +210,19 @@ class Recognizer(FastDeployModel):
|
||||
@rec_batch_num.setter
|
||||
def rec_batch_num(self, value):
|
||||
assert isinstance(
|
||||
value,
|
||||
int), "The value to set `rec_batch_num` must be type of int."
|
||||
value, int), "The value to set `rec_batch_num` must be type of int."
|
||||
self._model.rec_batch_num = value
|
||||
|
||||
|
||||
class PPOCRSystemv3(FastDeployModel):
|
||||
def __init__(self, det_model=None, cls_model=None, rec_model=None):
|
||||
assert det_model is not None and rec_model is not None, "The det_model and rec_model cannot be None."
|
||||
assert det_model is not None and rec_model is not None, "The det_model and rec_model cannot be None."
|
||||
if cls_model is None:
|
||||
self.system = C.vision.ocr.PPOCRSystemv3(det_model._model, rec_model._model)
|
||||
self.system = C.vision.ocr.PPOCRSystemv3(det_model._model,
|
||||
rec_model._model)
|
||||
else:
|
||||
self.system = C.vision.ocr.PPOCRSystemv3(det_model._model, cls_model._model, rec_model._model)
|
||||
self.system = C.vision.ocr.PPOCRSystemv3(
|
||||
det_model._model, cls_model._model, rec_model._model)
|
||||
|
||||
def predict(self, input_image):
|
||||
return self.system.predict(input_image)
|
||||
@@ -230,11 +230,13 @@ class PPOCRSystemv3(FastDeployModel):
|
||||
|
||||
class PPOCRSystemv2(FastDeployModel):
|
||||
def __init__(self, det_model=None, cls_model=None, rec_model=None):
|
||||
assert det_model is not None and rec_model is not None, "The det_model and rec_model cannot be None."
|
||||
assert det_model is not None and rec_model is not None, "The det_model and rec_model cannot be None."
|
||||
if cls_model is None:
|
||||
self.system = C.vision.ocr.PPOCRSystemv2(det_model._model, rec_model._model)
|
||||
self.system = C.vision.ocr.PPOCRSystemv2(det_model._model,
|
||||
rec_model._model)
|
||||
else:
|
||||
self.system = C.vision.ocr.PPOCRSystemv2(det_model._model, cls_model._model, rec_model._model)
|
||||
self.system = C.vision.ocr.PPOCRSystemv2(
|
||||
det_model._model, cls_model._model, rec_model._model)
|
||||
|
||||
def predict(self, input_image):
|
||||
return self.system.predict(input_image)
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from .... import FastDeployModel, Frontend
|
||||
from .... import FastDeployModel, ModelFormat
|
||||
from .... import c_lib_wrap as C
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ class PaddleSegModel(FastDeployModel):
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=Frontend.PADDLE):
|
||||
model_format=ModelFormat.PADDLE):
|
||||
super(PaddleSegModel, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == Frontend.PADDLE, "PaddleSeg only support model format of Frontend.Paddle now."
|
||||
assert model_format == ModelFormat.PADDLE, "PaddleSeg only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.segmentation.PaddleSegModel(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
|
Reference in New Issue
Block a user