Shortcuts

mmagic.apis.inferencers.matting_inferencer

Module Contents

Classes

MattingInferencer

inferencer that predicts with matting models.

class mmagic.apis.inferencers.matting_inferencer.MattingInferencer(config: Union[mmagic.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[source]

Bases: mmagic.apis.inferencers.base_mmagic_inferencer.BaseMMagicInferencer

inferencer that predicts with matting models.

func_kwargs[source]
preprocess(img: mmagic.apis.inferencers.base_mmagic_inferencer.InputsType, trimap: mmagic.apis.inferencers.base_mmagic_inferencer.InputsType) Dict[source]

Process the inputs into a model-feedable format.

Parameters
  • img (InputsType) – Image to be processed by models.

  • mask (InputsType) – Mask corresponding to the input image.

Returns

Results of preprocess.

Return type

results(Dict)

forward(inputs: mmagic.apis.inferencers.base_mmagic_inferencer.InputsType) mmagic.apis.inferencers.base_mmagic_inferencer.PredType[source]

Forward the inputs to the model.

visualize(preds: mmagic.apis.inferencers.base_mmagic_inferencer.PredType, result_out_dir: str = None) List[numpy.ndarray][source]

Visualize predictions.

Parameters
  • preds (List[Union[str, np.ndarray]]) – Forward results by the inferencer.

  • data (List[Dict]) – Not needed by this kind of inferencer.

  • result_out_dir (str) – Output directory of image. Defaults to ‘’.

Returns

Result of visualize

Return type

List[np.ndarray]

_pred2dict(data_sample: mmagic.structures.DataSample) Dict[source]

Extract elements necessary to represent a prediction into a dictionary. It’s better to contain only basic data elements such as strings and numbers in order to guarantee it’s json-serializable.

Parameters

data_sample (DataSample) – The data sample to be converted.

Returns

The output dictionary.

Return type

dict

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.