Shortcuts

mmedit.apis.inferencers.eg3d_inferencer

Module Contents

Classes

EG3DInferencer

Base inferencer.

Attributes

imageio

mmedit.apis.inferencers.eg3d_inferencer.imageio[source]
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)[source]

Bases: mmedit.apis.inferencers.base_mmedit_inferencer.BaseMMEditInferencer

Base inferencer.

Parameters
  • 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[source]
extra_parameters[source]
preprocess(inputs: mmedit.apis.inferencers.base_mmedit_inferencer.InputsType = None) mmedit.utils.ForwardInputs[source]

Process the inputs into a model-feedable format.

Parameters

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

Returns

The preprocessed inputs and data samples.

Return type

ForwardInputs

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

Forward the inputs to the model.

Parameters
  • 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.

Returns

Output dict corresponds to the input

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

Return type

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[source]

Visualize predictions.

Parameters
  • 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[source]

Preprocess images in the predictions.

Parameters

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

Returns

Preprocessed image tensor shape like

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

Return type

torch.Tensor

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

Preprocess depth in the predictions.

Parameters

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

Returns

Preprocessed depth tensor shape like

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

Return type

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][source]

Postprocess predictions.

Parameters
  • 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.

Returns

Inference results as a dict.

Return type

Dict[str, torch.Tensor]

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

Free document hosting provided by Read the Docs.