Shortcuts

mmedit.visualization.gen_visualizer

Module Contents

Classes

GenVisualizer

MMEditing Visualizer.

Attributes

mean_std_type

mmedit.visualization.gen_visualizer.mean_std_type[源代码]
class mmedit.visualization.gen_visualizer.GenVisualizer(name='visualizer', vis_backends: Optional[List[Dict]] = None, save_dir: Optional[str] = None)[源代码]

Bases: mmengine.visualization.Visualizer

MMEditing Visualizer.

参数
  • name (str) – Name of the instance. Defaults to ‘visualizer’.

  • vis_backends (list, optional) – Visual backend config list. Defaults to None.

  • save_dir (str, optional) – Save file dir for all storage backends. If it is None, the backend storage will not save any data.

Examples:

>>> # Draw image
>>> vis = GenVisualizer()
>>> vis.add_datasample(
>>>     'random_noise',
>>>     gen_samples=torch.rand(2, 3, 10, 10),
>>>     gt_samples=dict(imgs=torch.randn(2, 3, 10, 10)),
>>>     gt_keys='imgs',
>>>     vis_mode='image',
>>>     n_rows=2,
>>>     step=10)
static _post_process_image(image: torch.Tensor, color_order: str, mean: mean_std_type = None, std: mean_std_type = None) torch.Tensor[源代码]

Post process images. First convert image to rgb order. And then de-norm image to mean and std if they are passed.

参数
  • image (Tensor) – Image to pose process.

  • color_order (str) – The color order of the passed image.

  • mean (Optional[Sequence[Union[float, int]]], optional) – Target mean of the passed image. Defaults to None.

  • std (Optional[Sequence[Union[float, int]]], optional) – Target std of the passed image. Defaults to None.

返回

Image in original value range and RGB color order.

返回类型

Tensor

static _get_n_row_and_padding(samples: Tuple[dict, torch.Tensor], n_row: Optional[int] = None) Tuple[int, Optional[torch.Tensor]][源代码]

Get number of sample in each row and tensor for padding the empty position.

参数
  • samples (Tuple[dict, Tensor]) – Samples to visualize.

  • n_row (int, optional) – Number of images displayed in each row of. If not passed, n_row will be set as int(sqrt(batch_size)).

返回

Number of sample in each row and tensor

for padding the empty position.

返回类型

Tuple[int, Optional[int]]

_vis_gif_sample(gen_samples: mmedit.utils.typing.SampleList, target_keys: Union[str, List[str], None], color_order: str, target_mean: mean_std_type, target_std: mean_std_type, n_row: int) numpy.ndarray[源代码]

Visualize gif samples.

参数
  • gen_samples (SampleList) – List of data samples to visualize

  • target_keys (Union[str, List[str], None]) – Keys of the visualization target in data samples.

  • color_order (str) – The color order of the passed images.

  • target_mean (Sequence[Union[float, int]]) – The target mean of the visualization results.

  • target_std (Sequence[Union[float, int]]) – The target std of the visualization resutts.

  • n_rows (int, optional) – Number of images in one row.

返回

The visualization results.

返回类型

np.ndarray

_vis_image_sample(gen_samples: mmedit.utils.typing.SampleList, target_keys: Union[str, List[str], None], color_order: str, target_mean: mean_std_type, target_std: mean_std_type, n_row: int) numpy.ndarray[源代码]

Visualize image samples.

参数
  • gen_samples (SampleList) – List of data samples to visualize

  • target_keys (Union[str, List[str], None]) – Keys of the visualization target in data samples.

  • color_order (str) – The color order of the passed images.

  • target_mean (Sequence[Union[float, int]]) – The target mean of the visualization results.

  • target_std (Sequence[Union[float, int]]) – The target std of the visualization resutts.

  • n_rows (int, optional) – Number of images in one row.

返回

The visualization results.

返回类型

np.ndarray

_get_pixel_data_by_key(sample: mmedit.structures.EditDataSample, key: Union[str, List[str]]) torch.Tensor[源代码]

Get tensor in EditDataSample by the given key.

参数
  • sample (EditDataSample) – Input data sample.

  • key (Union[str, List[str]]) – Name of the target tensor.

返回

Tensor from the data sample.

返回类型

Tensor

add_datasample(name: str, *, gen_samples: Sequence[mmedit.structures.EditDataSample], target_keys: Optional[Tuple[str, List[str]]] = None, vis_mode: Optional[str] = None, n_row: Optional[int] = 1, color_order: str = 'bgr', target_mean: Sequence[Union[float, int]] = 127.5, target_std: Sequence[Union[float, int]] = 127.5, show: bool = False, wait_time: int = 0, step: int = 0, **kwargs) None[源代码]

Draw datasample and save to all backends.

If GT and prediction are plotted at the same time, they are displayed in a stitched image where the left image is the ground truth and the right image is the prediction.

If show is True, all storage backends are ignored, and the images will be displayed in a local window.

参数
  • name (str) – The image identifier.

  • gen_samples (List[EditDataSample]) – Data samples to visualize.

  • vis_mode (str, optional) – Visualization mode. If not passed, will visualize results as image. Defaults to None.

  • n_rows (int, optional) – Number of images in one row. Defaults to 1.

  • color_order (str) – The color order of the passed images. Defaults to ‘bgr’.

  • target_mean (Sequence[Union[float, int]]) – The target mean of the visualization results. Defaults to 127.5.

  • target_std (Sequence[Union[float, int]]) – The target std of the visualization resutts. Defaults to 127.5.

  • show (bool) – Whether to display the drawn image. Default to False.

  • wait_time (float) – The interval of show (s). Defaults to 0.

  • step (int) – Global step value to record. Defaults to 0.

add_image(name: str, image: numpy.ndarray, step: int = 0, **kwargs) None[源代码]

Record the image. Support input kwargs.

参数
  • name (str) – The image identifier.

  • image (np.ndarray, optional) – The image to be saved. The format should be RGB. Default to None.

  • step (int) – Global step value to record. Default to 0.

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.