mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 17:17:14 +08:00
[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:
@@ -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 = []
|
||||
|
Reference in New Issue
Block a user