Shortcuts

mmedit.structures

Package Contents

Classes

EditDataSample

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

PixelData

Data structure for pixel-level annnotations or predictions.

class mmedit.structures.EditDataSample(*, metainfo: Optional[dict] = None, **kwargs)[源代码]

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

This is the function to fetch gt_img in PixelData.

返回

data element

返回类型

PixelData

property gt_samples: EditDataSample

This is the function to fetch gt_samples.

返回

gt samples.

返回类型

EditDataSample

property noise: torch.Tensor

This is the function to fetch noise.

返回

noise.

返回类型

torch.Tensor

property pred_img: mmedit.structures.pixel_data.PixelData

This is the function to fetch pred_img in PixelData.

返回

data element

返回类型

PixelData

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

This is the function to fetch fake_img.

返回

The fake img.

返回类型

Union[PixelData, Tensor]

property img_lq: mmedit.structures.pixel_data.PixelData

This is the function to fetch img_lq in PixelData.

返回

data element

返回类型

PixelData

property ref_img: mmedit.structures.pixel_data.PixelData

This is the function to fetch ref_img.

返回

data element

返回类型

PixelData

property ref_lq: mmedit.structures.pixel_data.PixelData

This is the function to fetch ref_lq.

返回

data element

返回类型

PixelData

property gt_unsharp: mmedit.structures.pixel_data.PixelData

This is the function to fetch gt_unsharp in PixelData.

返回

data element

返回类型

PixelData

property mask: mmedit.structures.pixel_data.PixelData

This is the function to fetch mask.

返回

data element

返回类型

PixelData

property gt_heatmap: mmedit.structures.pixel_data.PixelData

This is the function to fetch gt_heatmap.

返回

data element

返回类型

PixelData

property pred_heatmap: mmedit.structures.pixel_data.PixelData

This is the function to fetch pred_heatmap.

返回

data element

返回类型

PixelData

property trimap: mmedit.structures.pixel_data.PixelData

This is the function to fetch trimap.

返回

data element

返回类型

PixelData

property gt_alpha: mmedit.structures.pixel_data.PixelData

This is the function to fetch gt_alpha.

返回

data element

返回类型

PixelData

property pred_alpha: mmedit.structures.pixel_data.PixelData

This is the function to fetch pred_alpha.

返回

data element

返回类型

PixelData

property gt_fg: mmedit.structures.pixel_data.PixelData

This is the function to fetch gt_fg.

返回

data element

返回类型

PixelData

property pred_fg: mmedit.structures.pixel_data.PixelData

This is the function to fetch pred_fg.

返回

_description_

返回类型

PixelData

property gt_bg: mmedit.structures.pixel_data.PixelData

This is the function to fetch gt_bg.

返回

data element

返回类型

PixelData

property pred_bg: mmedit.structures.pixel_data.PixelData

This is the function to fetch pred_bg in PixelData.

返回

data element

返回类型

PixelData

property gt_merged: mmedit.structures.pixel_data.PixelData

This is the function to fetch gt_merged in PixelData.

返回

_description_

返回类型

PixelData

property sample_model: str

This is the function to fetch sample model.

返回

Mode of Sample model.

返回类型

str

property ema: EditDataSample

This is the function to fetch ema results.

返回

Results of the ema model.

返回类型

EditDataSample

property orig: EditDataSample

This is the function to fetch original results.

返回

Results of the ema model.

返回类型

EditDataSample

property gt_label

This the function to fetch gt label.

返回

gt label.

返回类型

LabelData

gt_img()

This is the function to fetch gt_img.

gt_samples()

This is the function to delete gt_samples.

noise()

This is the functionto delete noise.

pred_img()

This is the function to fetch pred_img.

fake_img()

This is the function to delete fake_img.

img_lq()

This is the function to delete img_lq.

ref_img()

This is the function to fetch ref_img.

ref_lq()

This is the function to delete ref_lq.

gt_unsharp()

This is the function to delete gt_unsharp.

mask()

This is the function to delete mask.

gt_heatmap()

This is the function to delete gt_heatmap.

pred_heatmap()

This is the function to fetch pred_heatmap.

trimap()

This is the function to delete trimap.

gt_alpha()

This is the function to delete gt_alpha.

pred_alpha()

This is the function to delete pred_alpha.

gt_fg()

This is the function to delete gt_fg.

pred_fg()

This is the function to delete pred_fg.

gt_bg()

This is the function to delete gt_bg.

pred_bg()

This is the function to fetch pred_bg.

gt_merged()

This is the function to fetch gt_merged.

sample_model()

This is the function to delete sample model.

ema()

This is the function to delete ema results.

orig()

This is the function to delete ema results.

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

Set label of gt_label.

gt_label()

This is the function to delete gt label.

class mmedit.structures.PixelData(*, metainfo: Optional[dict] = None, **kwargs)[源代码]

Bases: mmengine.structures.PixelData

Data structure for pixel-level annnotations or predictions.

Different from parent class:

Support value.ndim == 4 for frames.

All data items in data_fields of PixelData meet the following requirements:

  • They all have 3 dimensions in orders of channel, height, and width.

  • They should have the same height and width.

实际案例

>>> metainfo = dict(
...     img_id=random.randint(0, 100),
...     img_shape=(random.randint(400, 600), random.randint(400, 600)))
>>> image = np.random.randint(0, 255, (4, 20, 40))
>>> featmap = torch.randint(0, 255, (10, 20, 40))
>>> pixel_data = PixelData(metainfo=metainfo,
...                        image=image,
...                        featmap=featmap)
>>> print(pixel_data)
>>> (20, 40)
>>> # slice
>>> slice_data = pixel_data[10:20, 20:40]
>>> assert slice_data.shape == (10, 10)
>>> slice_data = pixel_data[10, 20]
>>> assert slice_data.shape == (1, 1)
__setattr__(name: str, value: Union[torch.Tensor, numpy.ndarray])

Set attributes of PixelData.

If the dimension of value is 2 and its shape meet the demand, it will automatically expend its channel-dimension.

参数
  • name (str) – The key to access the value, stored in PixelData.

  • value (Union[torch.Tensor, np.ndarray]) – The value to store in. The type of value must be torch.Tensor or np.ndarray, and its shape must meet the requirements of PixelData.

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.