本文整理Python中os.makedirs方法的典型用法代码示例
示例1: save_to_path
# 需要导入模块: import os [as 别名]
# 或者: from os import makedirs [as 别名]
def save_to_path(self, filepath):
"""Save retrieved data to file at ``filepath``.
.. versionadded: 1.9.6
:param filepath: Path to save retrieved data.
"""
filepath = os.path.abspath(filepath)
dirname = os.path.dirname(filepath)
if not os.path.exists(dirname):
os.makedirs(dirname)
self.stream = True
with open(filepath, 'wb') as fileobj:
for data in self.iter_content():
fileobj.write(data)
示例2: savepb
# 需要导入模块: import os [as 别名]
# 或者: from os import makedirs [as 别名]
def savepb(self):
"""
Create a standalone const graph def that
C++ can load and run.
"""
darknet_pb = self.to_darknet()
flags_pb = self.FLAGS
flags_pb.verbalise = False
flags_pb.train = False
# rebuild another tfnet. all const.
tfnet_pb = TFNet(flags_pb, darknet_pb)
tfnet_pb.sess = tf.Session(graph = tfnet_pb.graph)
# tfnet_pb.predict() # uncomment for unit testing
name = 'built_graph/{}.pb'.format(self.meta['name'])
os.makedirs(os.path.dirname(name), exist_ok=True)
#Save dump of everything in meta
with open('built_graph/{}.meta'.format(self.meta['name']), 'w') as fp:
json.dump(self.meta, fp)
self.say('Saving const graph def to {}'.format(name))
graph_def = tfnet_pb.sess.graph_def
tf.train.write_graph(graph_def,'./', name, False)
浙公网安备 33010602011771号