1 Star 0 Fork 0

pauleta/OpenVINO-YoloV3

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
convert_weights_pb.py 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
PINTO0309 提交于 2018-12-16 10:07 . init
# -*- coding: utf-8 -*-
import numpy as np
import tensorflow as tf
import yolo_v3
import yolo_v3_tiny
from PIL import Image, ImageDraw
from utils import load_weights, load_coco_names, detections_boxes, freeze_graph
FLAGS = tf.app.flags.FLAGS
tf.app.flags.DEFINE_string(
'class_names', 'coco.names', 'File with class names')
tf.app.flags.DEFINE_string(
'weights_file', 'yolov3.weights', 'Binary file with detector weights')
tf.app.flags.DEFINE_string(
'data_format', 'NCHW', 'Data format: NCHW (gpu only) / NHWC')
tf.app.flags.DEFINE_string(
'output_graph', 'frozen_darknet_yolov3_model.pb', 'Frozen tensorflow protobuf model output path')
tf.app.flags.DEFINE_bool(
'tiny', False, 'Use tiny version of YOLOv3')
tf.app.flags.DEFINE_integer(
'size', 416, 'Image size')
def main(argv=None):
if FLAGS.tiny:
model = yolo_v3_tiny.yolo_v3_tiny
else:
model = yolo_v3.yolo_v3
classes = load_coco_names(FLAGS.class_names)
# placeholder for detector inputs
inputs = tf.placeholder(tf.float32, [None, FLAGS.size, FLAGS.size, 3], "inputs")
with tf.variable_scope('detector'):
detections = model(inputs, len(classes), data_format=FLAGS.data_format)
load_ops = load_weights(tf.global_variables(scope='detector'), FLAGS.weights_file)
#detect_1.shape = (?, 507, 85)
#detect_2.shape = (?, 2028, 85)
#detect_3.shape = (?, 8112, 85)
#detections.shape = (?, 10647, 85)
#detections = Tensor("detector/yolo-v3/detections:0", shape=(?, 10647, 85), dtype=float32)
print("detections.shape =", detections.shape)
print(detections)
print(detections.name)
# Sets the output nodes in the current session
boxes = detections_boxes(detections)
with tf.Session() as sess:
sess.run(load_ops)
freeze_graph(sess, FLAGS.output_graph, FLAGS.tiny)
if __name__ == '__main__':
tf.app.run()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pauleta/OpenVINO-YoloV3.git
git@gitee.com:pauleta/OpenVINO-YoloV3.git
pauleta
OpenVINO-YoloV3
OpenVINO-YoloV3
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385