py123detection.mmcv_export.writer¶
Writing the infos to a pickle that the training environment can read.
Conversion needs py123d (Python >= 3.9), while mmdetection3d setups are usually on Python 3.8 and numpy 1.x. Three things break a pickle across that gap:
Pickle protocol 5 is unreadable before Python 3.8, so the default is 4.
Any custom class (
pathlib.Path, a 123D enum, …) only unpickles where it is importable.validate_portable()rejects everything but built-ins and numpy arrays before writing.Arrays pickled under numpy 2 fail to load under numpy 1 (
No module named 'numpy._core'). Either installnumpy<2for the conversion, or writearray_format="portable", which stores arrays as nested lists and needspy123detection.mmcv_pluginto rebuild them.
Functions
|
The |
|
Write |
|
|
|
|
|
Recursively replace numpy arrays and scalars with lists and Python numbers. |
|
Raise |
Classes
|
Exceptions
The payload holds something that would not unpickle in a clean environment. |
- exception py123detection.mmcv_export.writer.PortabilityError[source]¶
Bases:
TypeErrorThe payload holds something that would not unpickle in a clean environment.
- class py123detection.mmcv_export.writer.WriteResult(path, num_infos, size_bytes, protocol, array_format, numpy_version, warnings)[source]¶
Bases:
object
- py123detection.mmcv_export.writer.validate_portable(obj, path='payload')[source]¶
Raise
PortabilityErroron the first value that needs more than built-ins and numpy to unpickle.- Return type:
- py123detection.mmcv_export.writer.to_portable_arrays(obj)[source]¶
Recursively replace numpy arrays and scalars with lists and Python numbers.
- Return type:
- py123detection.mmcv_export.writer.build_metadata(taxonomy_name, class_names, version, sources, extra=None)[source]¶
The
metadatablock stored next to the infos.mmdetection3d only reads
version; the rest records how the export was produced.
- py123detection.mmcv_export.writer.dump_infos(infos, output_path, metadata, protocol=DEFAULT_PICKLE_PROTOCOL, array_format='numpy', validate=True)[source]¶
Write
{'infos': ..., 'metadata': ...}for mmdetection3d.- Parameters:
protocol (
int) – 2 to 5. Anything above 4 warns, since it needs Python >= 3.8 to read.array_format (
str) –"numpy", or"portable"to store arrays as nested lists.validate (
bool) – Check the payload withvalidate_portable()before writing.
- Return type: