From 0334a262c5d04d97c2834b71234dc81c0c1d51ad Mon Sep 17 00:00:00 2001 From: Bobholamovic Date: Mon, 5 Sep 2022 19:36:02 +0800 Subject: [PATCH] net_initialize->initialize_net --- paddlers/tasks/base.py | 2 +- paddlers/tasks/change_detector.py | 10 +++++----- paddlers/tasks/classifier.py | 2 +- paddlers/tasks/object_detector.py | 2 +- paddlers/tasks/restorer.py | 2 +- paddlers/tasks/segmenter.py | 14 ++++++-------- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/paddlers/tasks/base.py b/paddlers/tasks/base.py index 5950691..0c32bb5 100644 --- a/paddlers/tasks/base.py +++ b/paddlers/tasks/base.py @@ -86,7 +86,7 @@ class BaseModel(metaclass=ModelMeta): self.quant_config = None self.fixed_input_shape = None - def net_initialize(self, + def initialize_net(self, pretrain_weights=None, save_dir='.', resume_checkpoint=None, diff --git a/paddlers/tasks/change_detector.py b/paddlers/tasks/change_detector.py index 6de48c7..afccdc4 100644 --- a/paddlers/tasks/change_detector.py +++ b/paddlers/tasks/change_detector.py @@ -316,7 +316,7 @@ class BaseChangeDetector(BaseModel): exit=True) pretrained_dir = osp.join(save_dir, 'pretrain') is_backbone_weights = pretrain_weights == 'IMAGENET' - self.net_initialize( + self.initialize_net( pretrain_weights=pretrain_weights, save_dir=pretrained_dir, resume_checkpoint=resume_checkpoint, @@ -607,13 +607,13 @@ class BaseChangeDetector(BaseModel): invalid_value (int, optional): Value that marks invalid pixels in output image. Defaults to 255. merge_strategy (str, optional): Strategy to merge overlapping blocks. Choices - are {'keep_first', 'keep_last', 'vote'}. 'keep_first' and 'keep_last' + are {'keep_first', 'keep_last', 'accum'}. 'keep_first' and 'keep_last' means keeping the values of the first and the last block in traversal - order, respectively. 'vote' means applying a simple voting strategy when - there are conflicts in the overlapping pixels. Defaults to 'keep_last'. + order, respectively. 'accum' means determining the class of an overlapping + pixel according to accumulated probabilities. Defaults to 'keep_last'. """ - slider_predict(self, img_files, save_dir, block_size, overlap, + slider_predict(self.predict, img_files, save_dir, block_size, overlap, transforms, invalid_value, merge_strategy) def preprocess(self, images, transforms, to_tensor=True): diff --git a/paddlers/tasks/classifier.py b/paddlers/tasks/classifier.py index 83c20fb..33ba5f3 100644 --- a/paddlers/tasks/classifier.py +++ b/paddlers/tasks/classifier.py @@ -288,7 +288,7 @@ class BaseClassifier(BaseModel): exit=True) pretrained_dir = osp.join(save_dir, 'pretrain') is_backbone_weights = False - self.net_initialize( + self.initialize_net( pretrain_weights=pretrain_weights, save_dir=pretrained_dir, resume_checkpoint=resume_checkpoint, diff --git a/paddlers/tasks/object_detector.py b/paddlers/tasks/object_detector.py index ca25213..313a893 100644 --- a/paddlers/tasks/object_detector.py +++ b/paddlers/tasks/object_detector.py @@ -347,7 +347,7 @@ class BaseDetector(BaseModel): "Invalid pretrained weights. Please specify a .pdparams file.", exit=True) pretrained_dir = osp.join(save_dir, 'pretrain') - self.net_initialize( + self.initialize_net( pretrain_weights=pretrain_weights, save_dir=pretrained_dir, resume_checkpoint=resume_checkpoint, diff --git a/paddlers/tasks/restorer.py b/paddlers/tasks/restorer.py index d9ce6ad..61691f0 100644 --- a/paddlers/tasks/restorer.py +++ b/paddlers/tasks/restorer.py @@ -283,7 +283,7 @@ class BaseRestorer(BaseModel): exit=True) pretrained_dir = osp.join(save_dir, 'pretrain') is_backbone_weights = pretrain_weights == 'IMAGENET' - self.net_initialize( + self.initialize_net( pretrain_weights=pretrain_weights, save_dir=pretrained_dir, resume_checkpoint=resume_checkpoint, diff --git a/paddlers/tasks/segmenter.py b/paddlers/tasks/segmenter.py index 8026b23..a319fc5 100644 --- a/paddlers/tasks/segmenter.py +++ b/paddlers/tasks/segmenter.py @@ -308,7 +308,7 @@ class BaseSegmenter(BaseModel): exit=True) pretrained_dir = osp.join(save_dir, 'pretrain') is_backbone_weights = pretrain_weights == 'IMAGENET' - self.net_initialize( + self.initialize_net( pretrain_weights=pretrain_weights, save_dir=pretrained_dir, resume_checkpoint=resume_checkpoint, @@ -579,15 +579,13 @@ class BaseSegmenter(BaseModel): invalid_value (int, optional): Value that marks invalid pixels in output image. Defaults to 255. merge_strategy (str, optional): Strategy to merge overlapping blocks. Choices - are {'keep_first', 'keep_last', 'vote', 'accum'}. 'keep_first' and - 'keep_last' means keeping the values of the first and the last block in - traversal order, respectively. 'vote' means applying a simple voting - strategy when there are conflicts in the overlapping pixels. 'accum' - means determining the class of an overlapping pixel according to - accumulated probabilities. Defaults to 'keep_last'. + are {'keep_first', 'keep_last', 'accum'}. 'keep_first' and 'keep_last' + means keeping the values of the first and the last block in traversal + order, respectively. 'accum' means determining the class of an overlapping + pixel according to accumulated probabilities. Defaults to 'keep_last'. """ - slider_predict(self, img_file, save_dir, block_size, overlap, + slider_predict(self.predict, img_file, save_dir, block_size, overlap, transforms, invalid_value, merge_strategy) def preprocess(self, images, transforms, to_tensor=True):