def main():
model = config.get('config', 'model')
yolo = importlib.import_module('model.' + model)
width = config.getint(model, 'width')
height = config.getint(model, 'height')
with tf.Session() as sess:
image = tf.placeholder(tf.float32, [1, height, width, 3], name='image')
builder = yolo.Builder(args, config)
builder(image)
global_step = tf.contrib.framework.get_or_create_global_step()
model_path = tf.train.latest_checkpoint(utils.get_logdir(config))
tf.logging.info('load ' + model_path)
slim.assign_from_checkpoint_fn(model_path, tf.global_variables())(sess)
tf.logging.info('global_step=%d' % sess.run(global_step))
path = os.path.expanduser(os.path.expandvars(args.path))
if os.path.isfile(path):
detect(sess, builder.model, builder.names, image, path)
plt.show()
else:
for dirpath, _, filenames in os.walk(path):
for filename in filenames:
if os.path.splitext(filename)[-1].lower() in args.exts:
_path = os.path.join(dirpath, filename)
print(_path)
detect(sess, builder.model, builder.names, image, _path)
plt.show()
评论列表
文章目录