Shortcuts

mmedit.apis.inferencers.eg3d_inferencer

Module Contents

Classes

EG3DInferencer

Base inferencer.

Attributes

imageio

mmedit.apis.inferencers.eg3d_inferencer.imageio[源代码]
class mmedit.apis.inferencers.eg3d_inferencer.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]

Read the Docs v: latest
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.