mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-15 13:10:55 +08:00
[Other] Add Model Clone function for PaddleClas && PaddleDet && PaddleSeg (#791)
* Refactor PaddleSeg with preprocessor && postprocessor * Fix bugs * Delete redundancy code * Modify by comments * Refactor according to comments * Add batch evaluation * Add single test script * Add ppliteseg single test script && fix eval(raise) error * fix bug * Fix evaluation segmentation.py batch predict * Fix segmentation evaluation bug * Fix evaluation segmentation bugs * Update segmentation result docs * Update old predict api and DisableNormalizeAndPermute * Update resize segmentation label map with cv::INTER_NEAREST * Add Model Clone function for PaddleClas && PaddleDet && PaddleSeg * Add multi thread demo * Add python model clone function * Add multi thread python && C++ example * Fix bug Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
@@ -99,6 +99,19 @@ class PPYOLOE(FastDeployModel):
|
||||
|
||||
return self._model.batch_predict(images)
|
||||
|
||||
def clone(self):
|
||||
"""Clone PPYOLOE object
|
||||
|
||||
:return: a new PPYOLOE object
|
||||
"""
|
||||
|
||||
class PPYOLOEClone(PPYOLOE):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = PPYOLOEClone(self._model.clone())
|
||||
return clone_model
|
||||
|
||||
@property
|
||||
def preprocessor(self):
|
||||
"""Get PaddleDetPreprocessor object of the loaded model
|
||||
@@ -139,6 +152,19 @@ class PPYOLO(PPYOLOE):
|
||||
model_format)
|
||||
assert self.initialized, "PPYOLO model initialize failed."
|
||||
|
||||
def clone(self):
|
||||
"""Clone PPYOLO object
|
||||
|
||||
:return: a new PPYOLO object
|
||||
"""
|
||||
|
||||
class PPYOLOClone(PPYOLO):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = PPYOLOClone(self._model.clone())
|
||||
return clone_model
|
||||
|
||||
|
||||
class PaddleYOLOX(PPYOLOE):
|
||||
def __init__(self,
|
||||
@@ -164,6 +190,19 @@ class PaddleYOLOX(PPYOLOE):
|
||||
model_format)
|
||||
assert self.initialized, "PaddleYOLOX model initialize failed."
|
||||
|
||||
def clone(self):
|
||||
"""Clone PaddleYOLOX object
|
||||
|
||||
:return: a new PaddleYOLOX object
|
||||
"""
|
||||
|
||||
class PaddleYOLOXClone(PaddleYOLOX):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = PaddleYOLOXClone(self._model.clone())
|
||||
return clone_model
|
||||
|
||||
|
||||
class PicoDet(PPYOLOE):
|
||||
def __init__(self,
|
||||
@@ -188,6 +227,19 @@ class PicoDet(PPYOLOE):
|
||||
model_format)
|
||||
assert self.initialized, "PicoDet model initialize failed."
|
||||
|
||||
def clone(self):
|
||||
"""Clone PicoDet object
|
||||
|
||||
:return: a new PicoDet object
|
||||
"""
|
||||
|
||||
class PicoDetClone(PicoDet):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = PicoDetClone(self._model.clone())
|
||||
return clone_model
|
||||
|
||||
|
||||
class FasterRCNN(PPYOLOE):
|
||||
def __init__(self,
|
||||
@@ -213,6 +265,19 @@ class FasterRCNN(PPYOLOE):
|
||||
model_format)
|
||||
assert self.initialized, "FasterRCNN model initialize failed."
|
||||
|
||||
def clone(self):
|
||||
"""Clone FasterRCNN object
|
||||
|
||||
:return: a new FasterRCNN object
|
||||
"""
|
||||
|
||||
class FasterRCNNClone(FasterRCNN):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = FasterRCNNClone(self._model.clone())
|
||||
return clone_model
|
||||
|
||||
|
||||
class YOLOv3(PPYOLOE):
|
||||
def __init__(self,
|
||||
@@ -238,6 +303,19 @@ class YOLOv3(PPYOLOE):
|
||||
model_format)
|
||||
assert self.initialized, "YOLOv3 model initialize failed."
|
||||
|
||||
def clone(self):
|
||||
"""Clone YOLOv3 object
|
||||
|
||||
:return: a new YOLOv3 object
|
||||
"""
|
||||
|
||||
class YOLOv3Clone(YOLOv3):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = YOLOv3Clone(self._model.clone())
|
||||
return clone_model
|
||||
|
||||
|
||||
class MaskRCNN(PPYOLOE):
|
||||
def __init__(self,
|
||||
@@ -273,6 +351,19 @@ class MaskRCNN(PPYOLOE):
|
||||
raise Exception(
|
||||
"batch_predict is not supported for MaskRCNN model now.")
|
||||
|
||||
def clone(self):
|
||||
"""Clone MaskRCNN object
|
||||
|
||||
:return: a new MaskRCNN object
|
||||
"""
|
||||
|
||||
class MaskRCNNClone(MaskRCNN):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = MaskRCNNClone(self._model.clone())
|
||||
return clone_model
|
||||
|
||||
|
||||
class SSD(PPYOLOE):
|
||||
def __init__(self,
|
||||
@@ -293,7 +384,20 @@ class SSD(PPYOLOE):
|
||||
super(PPYOLOE, self).__init__(runtime_option)
|
||||
|
||||
assert model_format == ModelFormat.PADDLE, "SSD model only support model format of ModelFormat.Paddle now."
|
||||
self._model = C.vision.detection.SSD(
|
||||
model_file, params_file, config_file, self._runtime_option,
|
||||
model_format)
|
||||
self._model = C.vision.detection.SSD(model_file, params_file,
|
||||
config_file, self._runtime_option,
|
||||
model_format)
|
||||
assert self.initialized, "SSD model initialize failed."
|
||||
|
||||
def clone(self):
|
||||
"""Clone SSD object
|
||||
|
||||
:return: a new SSD object
|
||||
"""
|
||||
|
||||
class SSDClone(SSD):
|
||||
def __init__(self, model):
|
||||
self._model = model
|
||||
|
||||
clone_model = SSDClone(self._model.clone())
|
||||
return clone_model
|
||||
|
Reference in New Issue
Block a user