Shortcuts

mmedit.structures.edit_data_sample

Module Contents

Classes

EditDataSample

A data structure interface of MMEditing. They are used as interfaces

Functions

format_label(→ mmengine.structures.LabelData)

Convert label of various python types to mmengine.LabelData.

mmedit.structures.edit_data_sample.format_label(value: Union[torch.Tensor, numpy.ndarray, Sequence, int], num_classes: int = None) mmengine.structures.LabelData[source]

Convert label of various python types to mmengine.LabelData.

Supported types are: numpy.ndarray, torch.Tensor, Sequence, int.

Parameters
  • value (torch.Tensor | numpy.ndarray | Sequence | int) – Label value.

  • num_classes (int, optional) – The number of classes. If not None, set it to the metainfo. Defaults to None.

Returns

The foramtted label data.

Return type

mmengine.LabelData

class mmedit.structures.edit_data_sample.EditDataSample(*, metainfo: Optional[dict] = None, **kwargs)[source]

Bases: mmengine.structures.BaseDataElement

A data structure interface of MMEditing. They are used as interfaces between different components.

The attributes in EditDataSample are divided into several parts:

  • gt_img: Ground truth image(s).

  • pred_img: Image(s) of model predictions.

  • ref_img: Reference image(s).

  • mask: Mask in Inpainting.

  • trimap: Trimap in Matting.

  • gt_alpha: Ground truth alpha image in Matting.

  • pred_alpha: Predicted alpha image in Matting.

  • gt_fg: Ground truth foreground image in Matting.

  • pred_fg: Predicted foreground image in Matting.

  • gt_bg: Ground truth background image in Matting.

  • pred_bg: Predicted background image in Matting.

  • gt_merged: Ground truth merged image in Matting.

Examples:

 >>> import torch
 >>> import numpy as np
 >>> from mmedit.structures import EditDataSample, PixelData
 >>> data_sample = EditDataSample()
 >>> img_meta = dict(img_shape=(800, 1196, 3))
 >>> img = torch.rand((3, 800, 1196))
 >>> gt_img = PixelData(data=img, metainfo=img_meta)
 >>> data_sample.gt_img = gt_img
 >>> assert 'img_shape' in data_sample.gt_img.metainfo_keys()
<EditDataSample(

    META INFORMATION

    DATA FIELDS
    _gt_img: <PixelData(

            META INFORMATION
            img_shape: (800, 1196, 3)

            DATA FIELDS
            data: tensor([[[0.8069, 0.4279,  ..., 0.6603, 0.0292],

                        ...,

                        [0.8139, 0.0908,  ..., 0.4964, 0.9672]]])
        ) at 0x1f6ae000af0>
    gt_img: <PixelData(

            META INFORMATION
            img_shape: (800, 1196, 3)

            DATA FIELDS
            data: tensor([[[0.8069, 0.4279,  ..., 0.6603, 0.0292],

                        ...,

                        [0.8139, 0.0908,  ..., 0.4964, 0.9672]]])
        ) at 0x1f6ae000af0>
) at 0x1f6a5a99a00>
property gt_img: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch gt_img in PixelData.

Returns

data element

Return type

PixelData

property gt_samples: EditDataSample[source]

This is the function to fetch gt_samples.

Returns

gt samples.

Return type

EditDataSample

property noise: torch.Tensor[source]

This is the function to fetch noise.

Returns

noise.

Return type

torch.Tensor

property pred_img: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch pred_img in PixelData.

Returns

data element

Return type

PixelData

property fake_img: Union[mmedit.structures.pixel_data.PixelData, torch.Tensor][source]

This is the function to fetch fake_img.

Returns

The fake img.

Return type

Union[PixelData, Tensor]

property img_lq: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch img_lq in PixelData.

Returns

data element

Return type

PixelData

property ref_img: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch ref_img.

Returns

data element

Return type

PixelData

property ref_lq: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch ref_lq.

Returns

data element

Return type

PixelData

property gt_unsharp: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch gt_unsharp in PixelData.

Returns

data element

Return type

PixelData

property mask: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch mask.

Returns

data element

Return type

PixelData

property gt_heatmap: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch gt_heatmap.

Returns

data element

Return type

PixelData

property pred_heatmap: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch pred_heatmap.

Returns

data element

Return type

PixelData

property trimap: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch trimap.

Returns

data element

Return type

PixelData

property gt_alpha: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch gt_alpha.

Returns

data element

Return type

PixelData

property pred_alpha: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch pred_alpha.

Returns

data element

Return type

PixelData

property gt_fg: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch gt_fg.

Returns

data element

Return type

PixelData

property pred_fg: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch pred_fg.

Returns

_description_

Return type

PixelData

property gt_bg: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch gt_bg.

Returns

data element

Return type

PixelData

property pred_bg: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch pred_bg in PixelData.

Returns

data element

Return type

PixelData

property gt_merged: mmedit.structures.pixel_data.PixelData[source]

This is the function to fetch gt_merged in PixelData.

Returns

_description_

Return type

PixelData

property sample_model: str[source]

This is the function to fetch sample model.

Returns

Mode of Sample model.

Return type

str

property ema: EditDataSample[source]

This is the function to fetch ema results.

Returns

Results of the ema model.

Return type

EditDataSample

property orig: EditDataSample[source]

This is the function to fetch original results.

Returns

Results of the ema model.

Return type

EditDataSample

property gt_label[source]

This the function to fetch gt label.

Returns

gt label.

Return type

LabelData

gt_img()[source]

This is the function to fetch gt_img.

gt_samples()[source]

This is the function to delete gt_samples.

noise()[source]

This is the functionto delete noise.

pred_img()[source]

This is the function to fetch pred_img.

fake_img()[source]

This is the function to delete fake_img.

img_lq()[source]

This is the function to delete img_lq.

ref_img()[source]

This is the function to fetch ref_img.

ref_lq()[source]

This is the function to delete ref_lq.

gt_unsharp()[source]

This is the function to delete gt_unsharp.

mask()[source]

This is the function to delete mask.

gt_heatmap()[source]

This is the function to delete gt_heatmap.

pred_heatmap()[source]

This is the function to fetch pred_heatmap.

trimap()[source]

This is the function to delete trimap.

gt_alpha()[source]

This is the function to delete gt_alpha.

pred_alpha()[source]

This is the function to delete pred_alpha.

gt_fg()[source]

This is the function to delete gt_fg.

pred_fg()[source]

This is the function to delete pred_fg.

gt_bg()[source]

This is the function to delete gt_bg.

pred_bg()[source]

This is the function to fetch pred_bg.

gt_merged()[source]

This is the function to fetch gt_merged.

sample_model()[source]

This is the function to delete sample model.

ema()[source]

This is the function to delete ema results.

orig()[source]

This is the function to delete ema results.

set_gt_label(value: Union[numpy.ndarray, torch.Tensor, Sequence[numbers.Number], numbers.Number]) EditDataSample[source]

Set label of gt_label.

gt_label()[source]

This is the function to delete gt label.

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.