本文整理汇总了Python中object_detection.utils.json_utils.Dump方法的典型用法代码示例。如果您正苦于以下问题:Python json_utils.Dump方法的具体用法?Python json_utils.Dump怎么用?Python json_utils.Dump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object_detection.utils.json_utils
的用法示例。
在下文中一共展示了json_utils.Dump方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dump_detections_to_json_file
# 需要导入模块: from object_detection.utils import json_utils [as 别名]
# 或者: from object_detection.utils.json_utils import Dump [as 别名]
def dump_detections_to_json_file(self, json_output_path):
"""Saves the detections into json_output_path in the format used by MS COCO.
Args:
json_output_path: String containing the output file's path. It can be also
None. In that case nothing will be written to the output file.
"""
if json_output_path and json_output_path is not None:
with tf.gfile.GFile(json_output_path, 'w') as fid:
tf.logging.info('Dumping detections to output json file.')
json_utils.Dump(
obj=self._detection_boxes_list, fid=fid, float_digits=4, indent=2)
示例2: testDumpReasonablePrecision
# 需要导入模块: from object_detection.utils import json_utils [as 别名]
# 或者: from object_detection.utils.json_utils import Dump [as 别名]
def testDumpReasonablePrecision(self):
output_path = os.path.join(tf.test.get_temp_dir(), 'test.json')
with tf.gfile.GFile(output_path, 'w') as f:
json_utils.Dump(1.0, f, float_digits=2)
with tf.gfile.GFile(output_path, 'r') as f:
self.assertEqual(f.read(), '1.00')
示例3: testDumpPassExtraParams
# 需要导入模块: from object_detection.utils import json_utils [as 别名]
# 或者: from object_detection.utils.json_utils import Dump [as 别名]
def testDumpPassExtraParams(self):
output_path = os.path.join(tf.test.get_temp_dir(), 'test.json')
with tf.gfile.GFile(output_path, 'w') as f:
json_utils.Dump([1.0], f, float_digits=2, indent=3)
with tf.gfile.GFile(output_path, 'r') as f:
self.assertEqual(f.read(), '[\n 1.00\n]')
示例4: testDumpZeroPrecision
# 需要导入模块: from object_detection.utils import json_utils [as 别名]
# 或者: from object_detection.utils.json_utils import Dump [as 别名]
def testDumpZeroPrecision(self):
output_path = os.path.join(tf.test.get_temp_dir(), 'test.json')
with tf.gfile.GFile(output_path, 'w') as f:
json_utils.Dump(1.0, f, float_digits=0, indent=3)
with tf.gfile.GFile(output_path, 'r') as f:
self.assertEqual(f.read(), '1')
示例5: testDumpUnspecifiedPrecision
# 需要导入模块: from object_detection.utils import json_utils [as 别名]
# 或者: from object_detection.utils.json_utils import Dump [as 别名]
def testDumpUnspecifiedPrecision(self):
output_path = os.path.join(tf.test.get_temp_dir(), 'test.json')
with tf.gfile.GFile(output_path, 'w') as f:
json_utils.Dump(1.012345, f)
with tf.gfile.GFile(output_path, 'r') as f:
self.assertEqual(f.read(), '1.012345')