[CVCUDA] wrap C processors in Python API (#1576)

* wrap C ops in Python API

* add comments

* change processor create style

* processors class inherit
This commit is contained in:
guxukai
2023-03-13 13:56:25 +08:00
committed by GitHub
parent 3d36e26b8a
commit f8d56a2424
3 changed files with 81 additions and 23 deletions

View File

@@ -2,6 +2,7 @@ import fastdeploy as fd
import cv2
from fastdeploy.vision.common.manager import PyProcessorManager
from fastdeploy.vision.common.processors import *
def parse_arguments():
@@ -20,29 +21,18 @@ class CustomProcessor(PyProcessorManager):
def __init__(self) -> None:
super().__init__()
# create op
hw = [500, 500]
self.resize_op = fd.C.vision.processors.ResizeByShort(100, 1, True, hw)
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
is_scale = True
min = []
max = []
swap_rb = False
self.normalize_permute_op = fd.C.vision.processors.NormalizeAndPermute(
mean, std, is_scale, min, max, swap_rb)
width = 50
height = 50
self.centercrop_op = fd.C.vision.processors.CenterCrop(width, height)
top = 5
bottom = 5
left = 5
right = 5
pad_value = [225, 225, 225]
self.pad_op = fd.C.vision.processors.Pad(top, bottom, left, right,
pad_value)
self.resize_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],
std=[0.229, 0.224, 0.225],
is_scale=True,
min=[],
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])
def apply(self, image_batch):
outputs = []