问题描述
我是 Tensorflow 的新手,目前正在研究将在 Tensorflow 中运行的 YOlov4 对象检测器。我从暗网 yolo 权重创建了一个冻结推理模型 .pb。现在我需要了解转换后的冻结模型输出节点的名称。我正在使用附加脚本将冻结图加载到会话中,并使用最后两行来获取和打印模型节点名称。但是,当我执行操作时,我得到一个空列表,这不应该是这种情况。你能帮我打这个野兽吗?请找到重现以下情况所需的代码。
import tensorflow as tf
import numpy as np
import sys
from tensorflow.python.ops.gen_array_ops import shape
def load_graph(frozen_graph_filename):
# We load the protobuf file from the disk and parse it to retrieve the
# unserialized graph_def
with tf.compat.v1.gfile.GFile(frozen_graph_filename,"rb") as f:
graph_def = tf.compat.v1.GraphDef()
graph_def.ParseFromString(f.read())
# Then,we import the graph_def into a new Graph and return it
with tf.compat.v1.Graph().as_default() as graph:
# The name var will prefix every op/nodes in your graph
# Since we load everything in a new graph,this is not needed
tf.compat.v1.import_graph_def(graph_def,name="prefix")
return graph
load_graph('./model.pb')
node_names = [n.name for n in tf.compat.v1.get_default_graph().as_graph_def().node]
print(node_names)
最后,在此链接中找到 tensorflow 冻结模型:https://drive.google.com/file/d/1MOa7MLMX6wvKvnV-43F5ZBOxMW8OeCMs/view?usp=sharing
我想请求您的仁慈,因为这是我在 Stack Overflow 上的第一篇文章,如果我的问题不完整,我深表歉意。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)