Shortcuts

PixelData

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

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.

Examples

>>> 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)
Read the Docs v: zyh/doc-notfound-extend
Versions
master
latest
stable
zyh-doc-notfound-extend
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.