MCPcopy Create free account
hub / github.com/Tencent/ObjectDetection-OneStageDet / serialize

Method serialize

brambox/boxes/box.py:91–114  ·  view source on GitHub ↗

Serialization function that can be overloaded in the derived class. The default serializer will call the serialize function of the bounding boxes and join them with a newline. Args: box: Bounding box objects Returns: string: Serialized bounding boxe

(self, box)

Source from the content-addressed store, hash-verified

89 pass
90
91 def serialize(self, box):
92 """ Serialization function that can be overloaded in the derived class.
93 The default serializer will call the serialize function of the bounding boxes and join them with a newline.
94
95 Args:
96 box: Bounding box objects
97
98 Returns:
99 string: Serialized bounding boxes
100
101 Note:
102 The format of the box parameter depends on the type of parser. |br|
103 If it is a :any:`brambox.boxes.box.ParserType.SINGLE_FILE`, the box parameter should be a dictionary ``{"image_id": [box, box, ...], ...}``. |br|
104 If it is a :any:`brambox.boxes.box.ParserType.MULTI_FILE`, the box parameter should be a list ``[box, box, ...]``.
105 """
106 if self.parser_type != ParserType.MULTI_FILE:
107 raise TypeError('The default implementation of serialize only works with MULTI_FILE')
108
109 result = ""
110 for b in box:
111 new_box = self.box_type.create(b)
112 result += new_box.serialize() + "\n"
113
114 return result
115
116 def deserialize(self, string):
117 """ Deserialization function that can be overloaded in the derived class.

Callers

nothing calls this directly

Calls 2

createMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected