MCPcopy Create free account
hub / github.com/open-mmlab/mmengine / set_data

Method set_data

mmengine/structures/base_data_element.py:235–248  ·  view source on GitHub ↗

Set or change key-value pairs in ``data_field`` by parameter ``data``. Args: data (dict): A dict contains annotations of image or model predictions.

(self, data: dict)

Source from the content-addressed store, hash-verified

233 self.set_field(name=k, value=v, field_type='metainfo', dtype=None)
234
235 def set_data(self, data: dict) -> None:
236 """Set or change key-value pairs in ``data_field`` by parameter
237 ``data``.
238
239 Args:
240 data (dict): A dict contains annotations of image or
241 model predictions.
242 """
243 assert isinstance(data,
244 dict), f'data should be a `dict` but got {data}'
245 for k, v in data.items():
246 # Use `setattr()` rather than `self.set_field` to allow `set_data`
247 # to set property method.
248 setattr(self, k, v)
249
250 def update(self, instance: 'BaseDataElement') -> None:
251 """The update() method updates the BaseDataElement with the elements

Callers 15

__init__Method · 0.95
updateMethod · 0.95
test_set_dataMethod · 0.95
newMethod · 0.80
cloneMethod · 0.80
toMethod · 0.80
cpuMethod · 0.80
cudaMethod · 0.80
musaMethod · 0.80
npuMethod · 0.80
mluMethod · 0.80
detachMethod · 0.80

Calls 1

itemsMethod · 0.45

Tested by 2

test_set_dataMethod · 0.76
test_newMethod · 0.64