Shortcuts

mmedit.structures.pixel_data

Module Contents

Classes

PixelData

Data structure for pixel-level annnotations or predictions.

class mmedit.structures.pixel_data.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.