Add verbose mode

own
Bobholamovic 2 years ago
parent 2f60abd899
commit db0cc05bfe
  1. 4
      docs/apis/infer.md
  2. 7
      paddlers/deploy/predictor.py
  3. 7
      paddlers/tasks/change_detector.py
  4. 7
      paddlers/tasks/segmenter.py

@ -158,7 +158,8 @@ def slider_predict(self,
transforms=None, transforms=None,
invalid_value=255, invalid_value=255,
merge_strategy='keep_last', merge_strategy='keep_last',
batch_size=1): batch_size=1,
quiet=False):
``` ```
输入参数列表: 输入参数列表:
@ -173,6 +174,7 @@ def slider_predict(self,
|`invalid_value`|`int`|输出影像中用于标记无效像素的数值。|`255`| |`invalid_value`|`int`|输出影像中用于标记无效像素的数值。|`255`|
|`merge_strategy`|`str`|合并滑窗重叠区域使用的策略。`'keep_first'`表示保留遍历顺序(从左至右,从上往下,列优先)最靠前的窗口的预测类别;`'keep_last'`表示保留遍历顺序最靠后的窗口的预测类别;`'accum'`表示通过将各窗口在重叠区域给出的预测概率累加,计算最终预测类别。需要注意的是,在对大尺寸影像进行`overlap`较大的密集推理时,使用`'accum'`策略可能导致较长的推理时间,但一般能够在窗口交界部分取得更好的表现。|`'keep_last'`| |`merge_strategy`|`str`|合并滑窗重叠区域使用的策略。`'keep_first'`表示保留遍历顺序(从左至右,从上往下,列优先)最靠前的窗口的预测类别;`'keep_last'`表示保留遍历顺序最靠后的窗口的预测类别;`'accum'`表示通过将各窗口在重叠区域给出的预测概率累加,计算最终预测类别。需要注意的是,在对大尺寸影像进行`overlap`较大的密集推理时,使用`'accum'`策略可能导致较长的推理时间,但一般能够在窗口交界部分取得更好的表现。|`'keep_last'`|
|`batch_size`|`int`|预测时使用的mini-batch大小。|`1`| |`batch_size`|`int`|预测时使用的mini-batch大小。|`1`|
|`quiet`|`bool`|若为`True`,不显示预测进度。|`False`|
变化检测任务的滑窗推理API与图像分割任务类似,但需要注意的是输出结果中存储的地理变换、投影等信息以从第一时相影像中读取的信息为准,存储滑窗推理结果的文件名也与第一时相影像文件相同。 变化检测任务的滑窗推理API与图像分割任务类似,但需要注意的是输出结果中存储的地理变换、投影等信息以从第一时相影像中读取的信息为准,存储滑窗推理结果的文件名也与第一时相影像文件相同。

@ -333,7 +333,8 @@ class Predictor(object):
transforms=None, transforms=None,
invalid_value=255, invalid_value=255,
merge_strategy='keep_last', merge_strategy='keep_last',
batch_size=1): batch_size=1,
quiet=False):
""" """
Do inference using sliding windows. Only semantic segmentation and change detection models are supported in the Do inference using sliding windows. Only semantic segmentation and change detection models are supported in the
sliding-predicting mode. sliding-predicting mode.
@ -357,6 +358,7 @@ class Predictor(object):
the last block in traversal order, respectively. 'accum' means determining the class of an overlapping pixel the last block in traversal order, respectively. 'accum' means determining the class of an overlapping pixel
according to accumulated probabilities. Defaults to 'keep_last'. according to accumulated probabilities. Defaults to 'keep_last'.
batch_size (int, optional): Batch size used in inference. Defaults to 1. batch_size (int, optional): Batch size used in inference. Defaults to 1.
quiet (bool, optional): If True, disable the progress bar. Defaults to False.
""" """
slider_predict( slider_predict(
partial( partial(
@ -368,7 +370,8 @@ class Predictor(object):
transforms, transforms,
invalid_value, invalid_value,
merge_strategy, merge_strategy,
batch_size) batch_size,
not quiet)
def batch_predict(self, image_list, **params): def batch_predict(self, image_list, **params):
return self.predict(img_file=image_list, **params) return self.predict(img_file=image_list, **params)

@ -589,7 +589,8 @@ class BaseChangeDetector(BaseModel):
transforms=None, transforms=None,
invalid_value=255, invalid_value=255,
merge_strategy='keep_last', merge_strategy='keep_last',
batch_size=1): batch_size=1,
quiet=False):
""" """
Do inference using sliding windows. Do inference using sliding windows.
@ -613,10 +614,12 @@ class BaseChangeDetector(BaseModel):
order, respectively. 'accum' means determining the class of an overlapping order, respectively. 'accum' means determining the class of an overlapping
pixel according to accumulated probabilities. Defaults to 'keep_last'. pixel according to accumulated probabilities. Defaults to 'keep_last'.
batch_size (int, optional): Batch size used in inference. Defaults to 1. batch_size (int, optional): Batch size used in inference. Defaults to 1.
quiet (bool, optional): If True, disable the progress bar. Defaults to False.
""" """
slider_predict(self.predict, img_files, save_dir, block_size, overlap, slider_predict(self.predict, img_files, save_dir, block_size, overlap,
transforms, invalid_value, merge_strategy, batch_size) transforms, invalid_value, merge_strategy, batch_size,
not quiet)
def preprocess(self, images, transforms, to_tensor=True): def preprocess(self, images, transforms, to_tensor=True):
self._check_transforms(transforms, 'test') self._check_transforms(transforms, 'test')

@ -561,7 +561,8 @@ class BaseSegmenter(BaseModel):
transforms=None, transforms=None,
invalid_value=255, invalid_value=255,
merge_strategy='keep_last', merge_strategy='keep_last',
batch_size=1): batch_size=1,
quiet=False):
""" """
Do inference using sliding windows. Do inference using sliding windows.
@ -585,10 +586,12 @@ class BaseSegmenter(BaseModel):
order, respectively. 'accum' means determining the class of an overlapping order, respectively. 'accum' means determining the class of an overlapping
pixel according to accumulated probabilities. Defaults to 'keep_last'. pixel according to accumulated probabilities. Defaults to 'keep_last'.
batch_size (int, optional): Batch size used in inference. Defaults to 1. batch_size (int, optional): Batch size used in inference. Defaults to 1.
quiet (bool, optional): If True, disable the progress bar. Defaults to False.
""" """
slider_predict(self.predict, img_file, save_dir, block_size, overlap, slider_predict(self.predict, img_file, save_dir, block_size, overlap,
transforms, invalid_value, merge_strategy, batch_size) transforms, invalid_value, merge_strategy, batch_size,
not quiet)
def preprocess(self, images, transforms, to_tensor=True): def preprocess(self, images, transforms, to_tensor=True):
self._check_transforms(transforms, 'test') self._check_transforms(transforms, 'test')

Loading…
Cancel
Save