Shortcuts

PixelData

class mmengine.structures.PixelData(*, metainfo=None, **kwargs)[源代码]

Data structure for pixel-level annotations or predictions.

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.shape)
(20, 40)
>>> # slice
>>> slice_data = pixel_data[10:20, 20:40]
>>> assert slice_data.shape == (10, 20)
>>> slice_data = pixel_data[10, 20]
>>> assert slice_data.shape == (1, 1)
>>> # set
>>> pixel_data.map3 = torch.randint(0, 255, (20, 40))
>>> assert tuple(pixel_data.map3.shape) == (1, 20, 40)
>>> with self.assertRaises(AssertionError):
...     # The dimension must be 3 or 2
...     pixel_data.map2 = torch.randint(0, 255, (1, 3, 20, 40))
参数

metainfo (Optional[dict]) –

返回类型

None

property shape

The shape of pixel data.

Read the Docs v: v0.8.5
Versions
latest
stable
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.