[CVCUDA]add op Python API: Cast, HWC2CHW, Normalize, PadToSize, Resize, StridePad (#1589)

* add Cast, HWC2CHW, Normalize, PadToSize, StridePad

* add comments

* fix comments

* fix manager.cc
This commit is contained in:
guxukai
2023-03-14 19:16:07 +08:00
committed by GitHub
parent 41ee93c75e
commit ab38c9110f
10 changed files with 268 additions and 13 deletions

View File

@@ -21,7 +21,7 @@ class CustomProcessor(PyProcessorManager):
def __init__(self) -> None:
super().__init__()
# create op
self.resize_op = ResizeByShort(
self.resize_short_op = ResizeByShort(
target_size=100, interp=1, use_scale=True, max_hw=[500, 500])
self.normalize_permute_op = NormalizeAndPermute(
mean=[0.485, 0.456, 0.406],
@@ -31,14 +31,37 @@ class CustomProcessor(PyProcessorManager):
max=[],
swap_rb=False)
self.centercrop_op = CenterCrop(width=50, height=50)
self.pad_op = Pad(
top=5, bottom=5, left=5, right=5, value=[225, 225, 225])
self.pad_op = Pad(top=5,
bottom=5,
left=5,
right=5,
value=[225, 225, 225])
self.cast_op = Cast(dtype="float")
self.hwc2chw_op = HWC2CHW()
self.normalize_op = Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225],
is_scale=True,
min=[],
max=[],
swap_rb=False)
self.pad_to_size_op = PadToSize(
height=160, width=160, value=[225, 225, 225])
self.resize_op = Resize(
width=50,
height=50,
scale_w=-1.0,
scale_h=-1.0,
interp=1,
use_scale=False)
self.stride_pad_op = StridePad(stride=3, value=[225, 225, 225])
def apply(self, image_batch):
outputs = []
self.resize_op(image_batch)
self.resize_short_op(image_batch)
self.centercrop_op(image_batch)
self.pad_op(image_batch)
self.pad_to_size_op(image_batch)
self.normalize_permute_op(image_batch)
for i in range(len(image_batch.mats)):