Shortcuts

mmedit.apis.inferencers

Package Contents

Classes

ColorizationInferencer

inferencer that predicts with colorization models.

ConditionalInferencer

inferencer that predicts with conditional models.

ControlnetAnimationInferencer

Base inferencer.

EG3DInferencer

Base inferencer.

ImageSuperResolutionInferencer

inferencer that predicts with restoration models.

InpaintingInferencer

inferencer that predicts with inpainting models.

MattingInferencer

inferencer that predicts with matting models.

Text2ImageInferencer

inferencer that predicts with text2image models.

TranslationInferencer

inferencer that predicts with translation models.

UnconditionalInferencer

inferencer that predicts with unconditional models.

VideoInterpolationInferencer

inferencer that predicts with video interpolation models.

VideoRestorationInferencer

inferencer that predicts with video restoration models.

Functions

calculate_grid_size(→ int)

Calculate the number of images per row (nrow) to make the grid closer to

colorization_inference(model, img)

Inference image with the model.

delete_cfg(cfg[, key])

Delete key from config object.

init_model(config[, checkpoint, device])

Initialize a model from config file.

inpainting_inference(model, masked_img, mask)

Inference image with the model.

matting_inference(model, img, trimap)

Inference image(s) with the model.

restoration_face_inference(model, img[, ...])

Inference image with the model.

restoration_inference(model, img[, ref])

Inference image with the model.

restoration_video_inference(model, img_dir, ...[, ...])

Inference image with the model.

sample_conditional_model(model[, num_samples, ...])

Sampling from conditional models.

sample_img2img_model(model, image_path[, target_domain])

Sampling from translation models.

sample_unconditional_model(model[, num_samples, ...])

Sampling from unconditional models.

set_random_seed(seed[, deterministic, use_rank_shift])

Set random seed.

video_interpolation_inference(model, input_dir, output_dir)

Inference image with the model.

class mmedit.apis.inferencers.ColorizationInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with colorization models.

func_kwargs
preprocess(img: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) Dict

Process the inputs into a model-feedable format.

参数

img (InputsType) – Image to be translated by models.

返回

Results of preprocess.

返回类型

results(Dict)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = None) List[numpy.ndarray]

Visualize predictions.

参数
  • 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 ‘’.

返回

Result of visualize

返回类型

List[np.ndarray]

class mmedit.apis.inferencers.ConditionalInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with conditional models.

func_kwargs
extra_parameters
preprocess(label: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) Dict

Process the inputs into a model-feedable format.

参数

label (InputsType) – Input label for condition models.

返回

Results of preprocess.

返回类型

results(Dict)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = None) List[numpy.ndarray]

Visualize predictions.

参数
  • 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 ‘’.

返回

Result of visualize

返回类型

List[np.ndarray]

_pred2dict(data_sample: mmedit.structures.EditDataSample) Dict

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.

参数

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

返回

The output dictionary.

返回类型

dict

class mmedit.apis.inferencers.ControlnetAnimationInferencer(config: Union[mmedit.utils.ConfigType, str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, dtype=torch.float32, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

Base inferencer.

参数
  • config (str or ConfigType) – Model config or the path to it.

  • ckpt (str, optional) – Path to the checkpoint.

  • device (str, optional) – Device to run inference. If None, the best device will be automatically used.

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

func_kwargs
func_order
extra_parameters
__call__(prompt=None, video=None, negative_prompt=None, controlnet_conditioning_scale=0.7, image_width=512, image_height=512, save_path=None, strength=0.75, num_inference_steps=20, seed=1, **kwargs) Union[Dict, List[Dict]]

Call the inferencer.

参数

kwargs – Keyword arguments for the inferencer.

返回

Results of inference pipeline.

返回类型

Union[Dict, List[Dict]]

class mmedit.apis.inferencers.EG3DInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

Base inferencer.

参数
  • config (str or ConfigType) – Model config or the path to it.

  • ckpt (str, optional) – Path to the checkpoint.

  • device (str, optional) – Device to run inference. If None, the best device will be automatically used.

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

func_kwargs
extra_parameters
preprocess(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType = None) mmedit.utils.ForwardInputs

Process the inputs into a model-feedable format.

参数

inputs (List[Union[str, np.ndarray]]) – The conditional inputs for the inferencer. Defaults to None.

返回

The preprocessed inputs and data samples.

返回类型

ForwardInputs

forward(inputs: mmedit.utils.ForwardInputs, interpolation: Optional[str] = 'both', num_images: int = 100) Union[dict, List[dict]]

Forward the inputs to the model.

参数
  • inputs (ForwardInputs) – Model inputs. If data sample (the second element of inputs) is not passed, will generate a sequence of images corresponding to passed interpolation mode.

  • interpolation (str) – The interplolation mode. Supported choices are ‘both’, ‘conditioning’, and ‘camera’. Defaults to ‘both’.

  • num_images (int) – The number of frames of interpolation. Defaults to 500.

返回

Output dict corresponds to the input

condition or the list of output dict of each frame during the interpolation process.

返回类型

Union[dict, List[dict]]

visualize(preds: Union[mmedit.apis.inferencers.base_mmedit_inferencer.PredType, List[mmedit.apis.inferencers.base_mmedit_inferencer.PredType]], vis_mode: str = 'both', save_img: bool = True, save_video: bool = True, img_suffix: str = '.png', video_suffix: str = '.mp4', result_out_dir: str = 'eg3d_output') None

Visualize predictions.

参数
  • preds (Union[PredType, List[PredType]]) – Prediction os model.

  • vis_mode (str, optional) – Which output to visualize. Supported choices are ‘both’, ‘depth’, and ‘img’. Defaults to ‘all’.

  • save_img (bool, optional) – Whether save images. Defaults to True.

  • save_video (bool, optional) – Whether save videos. Defaults to True.

  • img_suffix (str, optional) – The suffix of saved images. Defaults to ‘.png’.

  • video_suffix (str, optional) – The suffix of saved videos. Defaults to ‘.mp4’.

  • result_out_dir (str, optional) – The save director of image and videos. Defaults to ‘eg3d_output’.

preprocess_img(preds: List[dict]) torch.Tensor

Preprocess images in the predictions.

参数

preds (List[dict]) – List of prediction dict of each frame.

返回

Preprocessed image tensor shape like

[num_frame * bz, 3, H, W].

返回类型

torch.Tensor

preprocess_depth(preds: List[dict]) torch.Tensor

Preprocess depth in the predictions.

参数

preds (List[dict]) – List of prediction dict of each frame.

返回

Preprocessed depth tensor shape like

[num_frame * bz, 3, H, W].

返回类型

torch.Tensor

postprocess(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, imgs: Optional[List[numpy.ndarray]] = None, is_batch: bool = False, get_datasample: bool = False) Dict[str, torch.tensor]

Postprocess predictions.

参数
  • preds (List[Dict]) – Predictions of the model.

  • imgs (Optional[np.ndarray]) – Visualized predictions.

  • is_batch (bool) – Whether the inputs are in a batch. Defaults to False.

  • get_datasample (bool) – Whether to use Datasample to store inference results. If False, dict will be used.

返回

Inference results as a dict.

返回类型

Dict[str, torch.Tensor]

class mmedit.apis.inferencers.ImageSuperResolutionInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with restoration models.

func_kwargs
preprocess(img: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType, ref: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType = None) Dict

Process the inputs into a model-feedable format.

参数
  • img (InputsType) – Image to be restored by models.

  • ref (InputsType) – Reference image for resoration models. Defaults to None.

返回

Results of preprocess.

返回类型

data(Dict)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = None) List[numpy.ndarray]

Visualize predictions.

参数
  • 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 ‘’.

返回

Result of visualize

返回类型

List[np.ndarray]

mmedit.apis.inferencers.calculate_grid_size(num_batches: int = 1, aspect_ratio: int = 1) int[源代码]

Calculate the number of images per row (nrow) to make the grid closer to square when formatting a batch of images to grid.

参数
  • num_batches (int, optional) – Number of images per batch. Defaults to 1.

  • aspect_ratio (int, optional) – The aspect ratio (width / height) of each image sample. Defaults to 1.

返回

Calculated number of images per row.

返回类型

int

mmedit.apis.inferencers.colorization_inference(model, img)[源代码]

Inference image with the model.

参数
  • model (nn.Module) – The loaded model.

  • img (str) – Image file path.

返回

The predicted colorization result.

返回类型

Tensor

mmedit.apis.inferencers.delete_cfg(cfg, key='init_cfg')[源代码]

Delete key from config object.

参数
  • cfg (str or mmengine.Config) – Config object.

  • key (str) – Which key to delete.

mmedit.apis.inferencers.init_model(config, checkpoint=None, device='cuda:0')[源代码]

Initialize a model from config file.

参数
  • config (str or mmengine.Config) – Config file path or the config object.

  • checkpoint (str, optional) – Checkpoint path. If left as None, the model will not load any weights.

  • device (str) – Which device the model will deploy. Default: ‘cuda:0’.

返回

The constructed model.

返回类型

nn.Module

mmedit.apis.inferencers.inpainting_inference(model, masked_img, mask)[源代码]

Inference image with the model.

参数
  • model (nn.Module) – The loaded model.

  • masked_img (str) – File path of image with mask.

  • mask (str) – Mask file path.

返回

The predicted inpainting result.

返回类型

Tensor

mmedit.apis.inferencers.matting_inference(model, img, trimap)[源代码]

Inference image(s) with the model.

参数
  • model (nn.Module) – The loaded model.

  • img (str) – Image file path.

  • trimap (str) – Trimap file path.

返回

The predicted alpha matte.

返回类型

np.ndarray

mmedit.apis.inferencers.restoration_face_inference(model, img, upscale_factor=1, face_size=1024)[源代码]

Inference image with the model.

参数
  • model (nn.Module) – The loaded model.

  • img (str) – File path of input image.

  • upscale_factor (int, optional) – The number of times the input image is upsampled. Default: 1.

  • face_size (int, optional) – The size of the cropped and aligned faces. Default: 1024.

返回

The predicted restoration result.

返回类型

Tensor

mmedit.apis.inferencers.restoration_inference(model, img, ref=None)[源代码]

Inference image with the model.

参数
  • model (nn.Module) – The loaded model.

  • img (str) – File path of input image.

  • ref (str | None) – File path of reference image. Default: None.

返回

The predicted restoration result.

返回类型

Tensor

mmedit.apis.inferencers.restoration_video_inference(model, img_dir, window_size, start_idx, filename_tmpl, max_seq_len=None)[源代码]

Inference image with the model.

参数
  • model (nn.Module) – The loaded model.

  • img_dir (str) – Directory of the input video.

  • window_size (int) – The window size used in sliding-window framework. This value should be set according to the settings of the network. A value smaller than 0 means using recurrent framework.

  • start_idx (int) – The index corresponds to the first frame in the sequence.

  • filename_tmpl (str) – Template for file name.

  • max_seq_len (int | None) – The maximum sequence length that the model processes. If the sequence length is larger than this number, the sequence is split into multiple segments. If it is None, the entire sequence is processed at once.

返回

The predicted restoration result.

返回类型

Tensor

mmedit.apis.inferencers.sample_conditional_model(model, num_samples=16, num_batches=4, sample_model='ema', label=None, **kwargs)[源代码]

Sampling from conditional models.

参数
  • model (nn.Module) – Conditional models in MMGeneration.

  • num_samples (int, optional) – The total number of samples. Defaults to 16.

  • num_batches (int, optional) – The number of batch size for inference. Defaults to 4.

  • sample_model (str, optional) – Which model you want to use. [‘ema’, ‘orig’]. Defaults to ‘ema’.

  • label (int | torch.Tensor | list[int], optional) – Labels used to generate images. Default to None.,

返回

Generated image tensor.

返回类型

Tensor

mmedit.apis.inferencers.sample_img2img_model(model, image_path, target_domain=None, **kwargs)[源代码]

Sampling from translation models.

参数
  • model (nn.Module) – The loaded model.

  • image_path (str) – File path of input image.

  • style (str) – Target style of output image.

返回

Translated image tensor.

返回类型

Tensor

mmedit.apis.inferencers.sample_unconditional_model(model, num_samples=16, num_batches=4, sample_model='ema', **kwargs)[源代码]

Sampling from unconditional models.

参数
  • model (nn.Module) – Unconditional models in MMGeneration.

  • num_samples (int, optional) – The total number of samples. Defaults to 16.

  • num_batches (int, optional) – The number of batch size for inference. Defaults to 4.

  • sample_model (str, optional) – Which model you want to use. [‘ema’, ‘orig’]. Defaults to ‘ema’.

返回

Generated image tensor.

返回类型

Tensor

mmedit.apis.inferencers.set_random_seed(seed, deterministic=False, use_rank_shift=True)[源代码]

Set random seed.

In this function, we just modify the default behavior of the similar function defined in MMCV.

参数
  • seed (int) – Seed to be used.

  • deterministic (bool) – Whether to set the deterministic option for CUDNN backend, i.e., set torch.backends.cudnn.deterministic to True and torch.backends.cudnn.benchmark to False. Default: False.

  • rank_shift (bool) – Whether to add rank number to the random seed to have different random seed in different threads. Default: True.

mmedit.apis.inferencers.video_interpolation_inference(model, input_dir, output_dir, start_idx=0, end_idx=None, batch_size=4, fps_multiplier=0, fps=0, filename_tmpl='{:08d}.png')[源代码]

Inference image with the model.

参数
  • model (nn.Module) – The loaded model.

  • input_dir (str) – Directory of the input video.

  • output_dir (str) – Directory of the output video.

  • start_idx (int) – The index corresponding to the first frame in the sequence. Default: 0

  • end_idx (int | None) – The index corresponding to the last interpolated frame in the sequence. If it is None, interpolate to the last frame of video or sequence. Default: None

  • batch_size (int) – Batch size. Default: 4

  • fps_multiplier (float) – multiply the fps based on the input video. Default: 0.

  • fps (float) – frame rate of the output video. Default: 0.

  • filename_tmpl (str) – template of the file names. Default: ‘{:08d}.png’

class mmedit.apis.inferencers.InpaintingInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with inpainting models.

func_kwargs
_init_pipeline(cfg) mmengine.dataset.Compose

Initialize the test pipeline.

preprocess(img: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType, mask: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) Dict

Process the inputs into a model-feedable format.

参数
  • img (InputsType) – Image to be inpainted by models.

  • mask (InputsType) – Image mask for inpainting models.

返回

Results of preprocess.

返回类型

results(Dict)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = None) List[numpy.ndarray]

Visualize predictions.

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

  • data (List[Dict]) – Mask of input image.

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

返回

Result of visualize

返回类型

List[np.ndarray]

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

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with matting models.

func_kwargs
preprocess(img: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType, trimap: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) Dict

Process the inputs into a model-feedable format.

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

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

返回

Results of preprocess.

返回类型

results(Dict)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = None) List[numpy.ndarray]

Visualize predictions.

参数
  • 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 ‘’.

返回

Result of visualize

返回类型

List[np.ndarray]

_pred2dict(data_sample: mmedit.structures.EditDataSample) Dict

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.

参数

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

返回

The output dictionary.

返回类型

dict

class mmedit.apis.inferencers.Text2ImageInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with text2image models.

func_kwargs
extra_parameters
preprocess(text: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) Dict

Process the inputs into a model-feedable format.

参数

text (InputsType) – text input for text-to-image model.

返回

Results of preprocess.

返回类型

result(Dict)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = None) List[numpy.ndarray]

Visualize predictions.

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

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

返回

Result of visualize

返回类型

List[np.ndarray]

class mmedit.apis.inferencers.TranslationInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with translation models.

func_kwargs
preprocess(img: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) Dict

Process the inputs into a model-feedable format.

参数

img (InputsType) – Image to be translated by models.

返回

Results of preprocess.

返回类型

results(Dict)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = None) List[numpy.ndarray]

Visualize predictions.

参数
  • 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 ‘’.

返回

Result of visualize

返回类型

List[np.ndarray]

class mmedit.apis.inferencers.UnconditionalInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with unconditional models.

func_kwargs
extra_parameters
preprocess() Dict

Process the inputs into a model-feedable format.

返回

Results of preprocess.

返回类型

results(Dict)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = '') List[numpy.ndarray]

Visualize predictions.

参数
  • 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 ‘’.

返回

Result of visualize

返回类型

List[np.ndarray]

_pred2dict(data_sample: mmedit.structures.EditDataSample) Dict

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.

参数

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

返回

The output dictionary.

返回类型

dict

class mmedit.apis.inferencers.VideoInterpolationInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with video interpolation models.

func_kwargs
extra_parameters
preprocess(video: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) Dict

Process the inputs into a model-feedable format.

参数

video (InputsType) – Video to be interpolated by models.

返回

Video to be interpolated by models.

返回类型

video(InputsType)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType, result_out_dir: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType = '') mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

参数
  • inputs (InputsType) – Input video directory.

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

返回

Result of forwarding

返回类型

PredType

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = '') List[numpy.ndarray]

Visualize is not needed in this inferencer.

postprocess(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, imgs: Optional[List[numpy.ndarray]] = None) Union[mmedit.apis.inferencers.base_mmedit_inferencer.ResType, Tuple[mmedit.apis.inferencers.base_mmedit_inferencer.ResType, numpy.ndarray]]

Postprocess is not needed in this inferencer.

class mmedit.apis.inferencers.VideoRestorationInferencer(config: Union[mmedit.utils.ConfigType, str], ckpt: Optional[str], device: Optional[str] = None, extra_parameters: Optional[Dict] = None, seed: int = 2022, **kwargs)[源代码]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

inferencer that predicts with video restoration models.

func_kwargs
extra_parameters
preprocess(video: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) Dict

Process the inputs into a model-feedable format.

参数

video (InputsType) – Video to be restored by models.

返回

Results of preprocess.

返回类型

results(InputsType)

forward(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType) mmedit.apis.inferencers.base_mmedit_inferencer.PredType

Forward the inputs to the model.

参数

inputs (InputsType) – Images array of input video.

返回

Results of forwarding

返回类型

PredType

visualize(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, result_out_dir: str = '') List[numpy.ndarray]

Visualize predictions.

参数
  • 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 ‘’.

返回

Result of visualize

返回类型

List[np.ndarray]

postprocess(preds: mmedit.apis.inferencers.base_mmedit_inferencer.PredType, imgs: Optional[List[numpy.ndarray]] = None) Union[mmedit.apis.inferencers.base_mmedit_inferencer.ResType, Tuple[mmedit.apis.inferencers.base_mmedit_inferencer.ResType, numpy.ndarray]]

Postprocess is not needed in this inferencer.

Read the Docs v: dev-1.x
Versions
latest
stable
1.x
0.16.1
v0.16.0
v0.15.2
v0.15.1
v0.15.0
v0.14.0
v0.13.0
v0.12.0
dev-1.x
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.