[Model] Add Solov2 For PaddleDetection (#1435)

* update solov2

* Repair note

* update solov2 postprocess

* update

* update solov2

* update solov2

* fixed bug

* fixed bug

* update solov2

* update solov2

* fix build android bug

* update docs

* update docs

* update docs

* update

* update

* update arch and docs

* update

* update

* update solov2 python

---------

Co-authored-by: DefTruth <31974251+DefTruth@users.noreply.github.com>
This commit is contained in:
Zheng-Bicheng
2023-03-08 10:01:32 +08:00
committed by GitHub
parent 96a3698271
commit 0687d3b0ad
21 changed files with 840 additions and 474 deletions

View File

@@ -73,7 +73,10 @@ class PaddleDetPostprocessor:
"""
return self._postprocessor.run(runtime_results)
def apply_decode_and_nms(self, nms_option=None):
def apply_nms(self):
self.apply_nms()
def set_nms_option(self, nms_option=None):
"""This function will enable decode and nms in postprocess step.
"""
if nms_option is None:
@@ -340,6 +343,44 @@ class YOLOv3(PPYOLOE):
return clone_model
class SOLOv2(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a SOLOv2 model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g solov2/model.pdmodel
:param params_file: (str)Path of parameters file, e.g solov2/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 solov2/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)
assert model_format == ModelFormat.PADDLE, "SOLOv2 model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.SOLOv2(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "SOLOv2 model initialize failed."
def clone(self):
"""Clone SOLOv2 object
:return: a new SOLOv2 object
"""
class SOLOv2Clone(SOLOv2):
def __init__(self, model):
self._model = model
clone_model = SOLOv2Clone(self._model.clone())
return clone_model
class MaskRCNN(PPYOLOE):
def __init__(self,
model_file,