tensorflow-tensorboard打印网络结构

from __future__ import division, print_function

import tensorflow as tf
import numpy as np
import argparse
import cv2
import os
os.environ['CUDA_VISIBLE_DEVICES'] = "7"
from utils.misc_utils import parse_anchors, read_class_names
from utils.nms_utils import gpu_nms
from utils.plot_utils import get_color_table, plot_one_box
from utils.data_aug import letterbox_resize
from model import yolov3

parser = argparse.ArgumentParser(description="YOLO-V3 test single image test procedure.")
parser.add_argument("--input_path", type=str,default='/home/gyx/QR/qr_detect/YOLOv3_TensorFlow/data/demo_data/test_qr/',
                    help="The path of the input image.")
parser.add_argument("--save_path", type=str,default='/home/gyx/QR/qr_detect/YOLOv3_TensorFlow/data/demo_data/save_output/',
                    help="The path of the input image.")                    
parser.add_argument("--anchor_path", type=str, default="./data/yolo_anchors_320.txt",
                    help="The path of the anchor txt file.")
parser.add_argument("--new_size", nargs='*', type=int, default=[320, 320],
                    help="Resize the input image with `new_size`, size format: [width, height]")
parser.add_argument("--letterbox_resize", type=lambda x: (str(x).lower() == 'true'), default=True,
                    help="Whether to use the letterbox resize.")
parser.add_argument("--class_name_path", type=str, default="./data/data.names",
                    help="The path of the class names.")
parser.add_argument("--restore_path", type=str, default="./checkpoint_320/best_model_Epoch_44_step_18359_mAP_0.9307_loss_0.8562_lr_3e-05",
                    help="The path of the weights to restore.")
args = parser.parse_args()

args.anchors = parse_anchors(args.anchor_path)
args.classes = read_class_names(args.class_name_path)
args.num_class = len(args.classes)
# color_table = get_color_table(args.num_class)
color_table = {}
color_table[0] = [250,0,0]
img_list=os.listdir(args.input_path)
# print(img_list)

with tf.Session() as sess:
    input_data = tf.placeholder(tf.float32, [1, args.new_size[1], args.new_size[0], 3], name='input_data')
    yolo_model = yolov3(args.num_class, args.anchors)
    with tf.variable_scope('yolov3'):
        pred_feature_maps = yolo_model.forward(input_data, False)
    pred_boxes, pred_confs, pred_probs = yolo_model.predict(pred_feature_maps)

    pred_scores = pred_confs * pred_probs

    boxes, scores, labels = gpu_nms(pred_boxes, pred_scores, args.num_class, max_boxes=200, score_thresh=0.3, nms_thresh=0.45)

    saver = tf.train.Saver()
    saver.restore(sess, args.restore_path)

    ###########################重点区域#################################
    init = tf.initialize_all_variables()
    merged = tf.summary.merge_all()
    writer = tf.summary.FileWriter("./log/",sess.graph) #目录结构尽量简单,复杂了容易出现找不到文件,原因不清楚
    sess.run(init)
    print("tensorboard --logdir=./log  --host=127.0.0.1")

点击链接或者在命令行输入:tensorboard --logdir=./log  --host=127.0.0.1

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值