本文整理匯總了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')