Matting(图像抠图)#
fastdeploy.vision.matting.MODNet#
- class fastdeploy.vision.matting.MODNet(model_file, params_file='', runtime_option=None, model_format=<ModelFormat.ONNX: 2>)[source]#
Load a MODNet model exported by MODNet.
- Parameters
model_file – (str)Path of model file, e.g ./modnet.onnx
params_file – (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
runtime_option – (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it’s None, will use the default backend on CPU
model_format – (fastdeploy.ModelForamt)Model format of the loaded model
- property alpha#
Argument for image preprocessing step, alpha value for normalization, default alpha = {1.f / 127.5f, 1.f / 127.5f, 1.f / 127.5f}
- property beta#
Argument for image preprocessing step, beta value for normalization, default beta = {-1.f, -1.f, -1.f}
- get_profile_time()#
Get profile time of Runtime after the profile process is done.
- predict(input_image)[source]#
Predict the matting result for an input image
- Parameters
input_image – (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
- Returns
MattingResult
- property size#
Argument for image preprocessing step, the preprocess image size, tuple of (width, height), default size = [256,256]
- property swap_rb#
Argument for image preprocessing step, whether to swap the B and R channel, such as BGR->RGB, default True.
fastdeploy.vision.matting.PPMatting#
- class fastdeploy.vision.matting.PPMatting(model_file, params_file, config_file, runtime_option=None, model_format=<ModelFormat.PADDLE: 1>)[source]#
Load a PPMatting model exported by PaddleSeg.
- Parameters
model_file – (str)Path of model file, e.g PPMatting-512/model.pdmodel
params_file – (str)Path of parameters file, e.g PPMatting-512/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
config_file – (str)Path of configuration file for deployment, e.g PPMatting-512/deploy.yml
runtime_option – (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it’s None, will use the default backend on CPU
model_format – (fastdeploy.ModelForamt)Model format of the loaded model
- get_profile_time()#
Get profile time of Runtime after the profile process is done.
fastdeploy.vision.matting.RobustVideoMatting#
- class fastdeploy.vision.matting.RobustVideoMatting(model_file, params_file='', runtime_option=None, model_format=<ModelFormat.ONNX: 2>)[source]#
Load a video matting model exported by RobustVideoMatting.
- Parameters
model_file – (str)Path of model file, e.g rvm/rvm_mobilenetv3_fp32.onnx
params_file – (str)Path of parameters file, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
runtime_option – (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it’s None, will use the default backend on CPU
model_format – (fastdeploy.ModelForamt)Model format of the loaded model, default is ONNX
- get_profile_time()#
Get profile time of Runtime after the profile process is done.
- predict(input_image)[source]#
Matting an input image
- Parameters
im – (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
- Returns
MattingResult
- property size#
Returns the preprocess image size
- property swap_rb#
Whether convert to RGB, Set to false if you have converted YUV format images to RGB outside the model, dafault true
- property video_mode#
Whether to open the video mode, if there are some irrelevant pictures, set it to fasle, the default is true