mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 09:07:10 +08:00
[Hackthon_4th 177] Support PP-YOLOE-R with BM1684 (#1809)
* first draft * add robx iou * add benchmark for ppyoloe_r * remove trash code * fix bugs * add pybind nms rotated option * add missing head file * fix bug * fix bug2 * fix shape bug --------- Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
This commit is contained in:
@@ -50,6 +50,15 @@ class NMSOption:
|
||||
return self.nms_option.background_label
|
||||
|
||||
|
||||
class NMSRotatedOption:
|
||||
def __init__(self):
|
||||
self.nms_rotated_option = C.vision.detection.NMSRotatedOption()
|
||||
|
||||
@property
|
||||
def background_label(self):
|
||||
return self.nms_rotated_option.background_label
|
||||
|
||||
|
||||
class PaddleDetPostprocessor:
|
||||
def __init__(self):
|
||||
"""Create a postprocessor for PaddleDetection Model
|
||||
@@ -75,6 +84,14 @@ class PaddleDetPostprocessor:
|
||||
nms_option = NMSOption()
|
||||
self._postprocessor.set_nms_option(self, nms_option.nms_option)
|
||||
|
||||
def set_nms_rotated_option(self, nms_rotated_option=None):
|
||||
"""This function will enable decode and rotated nms in postprocess step.
|
||||
"""
|
||||
if nms_rotated_option is None:
|
||||
nms_rotated_option = NMSRotatedOption()
|
||||
self._postprocessor.set_nms_rotated_option(
|
||||
self, nms_rotated_option.nms_rotated_option)
|
||||
|
||||
|
||||
class PPYOLOE(FastDeployModel):
|
||||
def __init__(self,
|
||||
@@ -781,3 +798,40 @@ class GFL(PPYOLOE):
|
||||
config_file, self._runtime_option,
|
||||
model_format)
|
||||
assert self.initialized, "GFL model initialize failed."
|
||||
|
||||
|
||||
class PPYOLOER(PPYOLOE):
|
||||
def __init__(self,
|
||||
model_file,
|
||||
params_file,
|
||||
config_file,
|
||||
runtime_option=None,
|
||||
model_format=ModelFormat.PADDLE):
|
||||
"""Load a PPYOLOER model exported by PaddleDetection.
|
||||
|
||||
:param model_file: (str)Path of model file, e.g ppyoloe_r/model.pdmodel
|
||||
:param params_file: (str)Path of parameters file, e.g ppyoloe_r/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
|
||||
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe_r/infer_cfg.yml
|
||||
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
|
||||
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
|
||||
"""
|
||||
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
self._model = C.vision.detection.PPYOLOER(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
assert self.initialized, "PicoDet model initialize failed."
|
||||
|
||||
def clone(self):
|
||||
"""Clone PPYOLOER object
|
||||
|
||||
:return: a new PPYOLOER object
|
||||
"""
|
||||
|
||||
class PPYOLOERClone(PPYOLOER):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = PPYOLOERClone(self._model.clone())
|
||||
return clone_model
|
||||
|
Reference in New Issue
Block a user