mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-05 16:48:03 +08:00
Refine cpp/python api of visualize with lots of deprecated apis (#303)
* fix patchelf * refine visualize api * Update CMakeLists.txt * refine visualize api * add libs directory * Create __init__.py
This commit is contained in:
@@ -22,39 +22,51 @@ def vis_detection(im_data,
|
||||
score_threshold=0.0,
|
||||
line_size=1,
|
||||
font_size=0.5):
|
||||
return C.vision.Visualize.vis_detection(
|
||||
im_data, det_result, score_threshold, line_size, font_size)
|
||||
return C.vision.vis_detection(im_data, det_result, score_threshold,
|
||||
line_size, font_size)
|
||||
|
||||
|
||||
def vis_face_detection(im_data, face_det_result, line_size=1, font_size=0.5):
|
||||
return C.vision.Visualize.vis_face_detection(im_data, face_det_result,
|
||||
line_size, font_size)
|
||||
return C.vision.vis_face_detection(im_data, face_det_result, line_size,
|
||||
font_size)
|
||||
|
||||
|
||||
def vis_segmentation(im_data, seg_result):
|
||||
return C.vision.Visualize.vis_segmentation(im_data, seg_result)
|
||||
return C.vision.vis_segmentation(im_data, seg_result)
|
||||
|
||||
|
||||
def vis_matting_alpha(im_data,
|
||||
matting_result,
|
||||
remove_small_connected_area=False):
|
||||
return C.vision.Visualize.vis_matting_alpha(im_data, matting_result,
|
||||
remove_small_connected_area)
|
||||
logging.warning(
|
||||
"DEPRECATED: fastdeploy.vision.vis_matting_alpha is deprecated, please use fastdeploy.vision.vis_matting function instead."
|
||||
)
|
||||
return C.vision.vis_matting(im_data, matting_result,
|
||||
remove_small_connected_area)
|
||||
|
||||
|
||||
def vis_matting(im_data, matting_result, remove_small_connected_area=False):
|
||||
return C.vision.vis_matting(im_data, matting_result,
|
||||
remove_small_connected_area)
|
||||
|
||||
|
||||
def swap_background_matting(im_data,
|
||||
background,
|
||||
result,
|
||||
remove_small_connected_area=False):
|
||||
logging.warning(
|
||||
"DEPRECATED: fastdeploy.vision.swap_background_matting is deprecated, please use fastdeploy.vision.swap_background function instead."
|
||||
)
|
||||
assert isinstance(
|
||||
result,
|
||||
C.vision.MattingResult), "The result must be MattingResult type"
|
||||
result, C.vision.MattingResult), "The result must be MattingResult type"
|
||||
return C.vision.Visualize.swap_background_matting(
|
||||
im_data, background, result, remove_small_connected_area)
|
||||
|
||||
|
||||
def swap_background_segmentation(im_data, background, background_label,
|
||||
result):
|
||||
def swap_background_segmentation(im_data, background, background_label, result):
|
||||
logging.warning(
|
||||
"DEPRECATED: fastdeploy.vision.swap_background_segmentation is deprecated, please use fastdeploy.vision.swap_background function instead."
|
||||
)
|
||||
assert isinstance(
|
||||
result, C.vision.
|
||||
SegmentationResult), "The result must be SegmentaitonResult type"
|
||||
@@ -62,9 +74,22 @@ def swap_background_segmentation(im_data, background, background_label,
|
||||
im_data, background, background_label, result)
|
||||
|
||||
|
||||
def remove_small_connected_area(alpha_pred_data, threshold):
|
||||
assert len(alpha_pred_data.shape) == 3, "alpha has a (h, w, 1) shape"
|
||||
return C.vision.Visualize.remove_small_connected_area(alpha_pred_data,
|
||||
threshold)
|
||||
def swap_background(im_data,
|
||||
background,
|
||||
result,
|
||||
remove_small_connected_area=False,
|
||||
background_label=0):
|
||||
if isinstance(result, C.vision.MattingResult):
|
||||
return C.vision.swap_background(im_data, background, result,
|
||||
remove_small_connected_area)
|
||||
elif isinstance(result, C.vision.SegmentationResult):
|
||||
return C.vision.swap_background(im_data, background, result,
|
||||
background_label)
|
||||
else:
|
||||
raise Exception(
|
||||
"Only support result type of MattingResult or SegmentationResult, but now the data type is {}.".
|
||||
format(type(result)))
|
||||
|
||||
|
||||
def vis_ppocr(im_data, det_result):
|
||||
return C.vision.Visualize.vis_ppocr(im_data, det_result)
|
||||
return C.vision.vis_ppocr(im_data, det_result)
|
||||
|
Reference in New Issue
Block a user