[Fix] Fix predictor and imgdecoder

own
Bobholamovic 3 years ago
parent 267c4d3c9f
commit bc56d25f17
  1. 2
      paddlers/deploy/predictor.py
  2. 42
      paddlers/transforms/operators.py

@ -275,7 +275,7 @@ class Predictor(object):
self.timer.img_num = len(images) self.timer.img_num = len(images)
self.timer.info(average=True) self.timer.info(average=True)
if isinstance(img_file, (str, np.ndarray)): if isinstance(img_file, (str, np.ndarray, tuple)):
results = results[0] results = results[0]
return results return results

@ -35,13 +35,33 @@ from .functions import normalize, horizontal_flip, permute, vertical_flip, cente
to_intensity, to_uint8, img_flip, img_simple_rotate to_intensity, to_uint8, img_flip, img_simple_rotate
__all__ = [ __all__ = [
"Compose", "ImgDecoder", "Resize", "RandomResize", "ResizeByShort", "Compose",
"RandomResizeByShort", "ResizeByLong", "RandomHorizontalFlip", "ImgDecoder",
"RandomVerticalFlip", "Normalize", "CenterCrop", "RandomCrop", "Resize",
"RandomScaleAspect", "RandomExpand", "Padding", "MixupImage", "RandomResize",
"RandomDistort", "RandomBlur", "RandomSwap", "Defogging", "DimReducing", "ResizeByShort",
"BandSelecting", "ArrangeSegmenter", "ArrangeChangeDetector", "RandomResizeByShort",
"ArrangeClassifier", "ArrangeDetector", "RandomFlipOrRotation", "ResizeByLong",
"RandomHorizontalFlip",
"RandomVerticalFlip",
"Normalize",
"CenterCrop",
"RandomCrop",
"RandomScaleAspect",
"RandomExpand",
"Padding",
"MixupImage",
"RandomDistort",
"RandomBlur",
"RandomSwap",
"Defogging",
"DimReducing",
"BandSelecting",
"ArrangeSegmenter",
"ArrangeChangeDetector",
"ArrangeClassifier",
"ArrangeDetector",
"RandomFlipOrRotation",
] ]
interp_dict = { interp_dict = {
@ -179,13 +199,17 @@ class ImgDecoder(Transform):
def apply(self, sample): def apply(self, sample):
""" """
Args: Args:
sample (dict): Input sample, containing 'image' at least. sample (dict): Input sample.
Returns: Returns:
dict: Decoded sample. dict: Decoded sample.
""" """
if 'image' in sample: if 'image' in sample:
sample['image'] = self.apply_im(sample['image']) sample['image'] = self.apply_im(sample['image'])
else: # image_tx if 'image2' in sample:
sample['image2'] = self.apply_im(sample['image2'])
if 'image_t1' in sample and not 'image' in sample:
if not ('image_t2' in sample and 'image2' not in sample):
raise ValueError
sample['image'] = self.apply_im(sample['image_t1']) sample['image'] = self.apply_im(sample['image_t1'])
sample['image2'] = self.apply_im(sample['image_t2']) sample['image2'] = self.apply_im(sample['image_t2'])
if 'mask' in sample: if 'mask' in sample:

Loading…
Cancel
Save