Google colaboratory 可视化对象检测图时,TensorBoard会挂起
我需要可视化TensorFlow对象检测模型的结构。我正在尝试在Colab中使用TensorBoard,代码如下。当TensorBoard加载日志时,它会停留在“名称空间层次结构:查找类似子图”的步骤上 以下是指向笔记本的链接: 环境: 浏览器:Chrome 操作系统:Windows 内存:8GB 最后,我开始得到下面的错误 仅供参考,我尝试在一台内存为4GB的Windows计算机上运行相同的进程,同时在一个外壳中运行一个TensorBoard服务器。我使用默认URL访问TensorBoard(在笔记本之外)。它在启动过程中的同一点失败 我看到了这一点,并提出了类似的问题,但没有提供答案 提前感谢——这对我为公司做的重要项目真的很有帮助Google colaboratory 可视化对象检测图时,TensorBoard会挂起,google-colaboratory,tensorflow2.0,tensorboard,Google Colaboratory,Tensorflow2.0,Tensorboard,我需要可视化TensorFlow对象检测模型的结构。我正在尝试在Colab中使用TensorBoard,代码如下。当TensorBoard加载日志时,它会停留在“名称空间层次结构:查找类似子图”的步骤上 以下是指向笔记本的链接: 环境: 浏览器:Chrome 操作系统:Windows 内存:8GB 最后,我开始得到下面的错误 仅供参考,我尝试在一台内存为4GB的Windows计算机上运行相同的进程,同时在一个外壳中运行一个TensorBoard服务器。我使用默认URL访问TensorBoard(
我相信我现在知道如何解决三个问题
import tensorflow as tf
import numpy as np
!pip install -U tensorflow
%load_ext tensorboard
# Download model
!wget http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.tar.gz
!tar -xf ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.tar.gz
model_dir = '/content/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8/saved_model'
log_dir = '/content/logs'
if os.path.exists(log_dir):
! rm -r $log_dir
@tf.function
def f(x):
imported = tf.saved_model.load(model_dir)
results = imported(x)
return results
#Initialize variables
imgs = np.zeros((1,640,640,3),dtype=int)
imgs_t = tf.constant(imgs, dtype=tf.dtypes.uint8)
imported_g = f.get_concrete_function(imgs_t).graph
# Export the graph
with session.Session(graph=imported_g) as sess:
pb_visual_writer = summary.FileWriter(log_dir)
pb_visual_writer.add_graph(sess.graph)
print("Model Imported. Visualize by running: "
"tensorboard --logdir={}".format(log_dir))
新图形显示图形的边,而不仅仅是节点
以下是您可以运行的笔记本:
import tensorflow as tf
import numpy as np
!pip install -U tensorflow
%load_ext tensorboard
# Download model
!wget http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.tar.gz
!tar -xf ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.tar.gz
model_dir = '/content/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8/saved_model'
log_dir = '/content/logs'
if os.path.exists(log_dir):
! rm -r $log_dir
@tf.function
def f(x):
imported = tf.saved_model.load(model_dir)
results = imported(x)
return results
#Initialize variables
imgs = np.zeros((1,640,640,3),dtype=int)
imgs_t = tf.constant(imgs, dtype=tf.dtypes.uint8)
imported_g = f.get_concrete_function(imgs_t).graph
# Export the graph
with session.Session(graph=imported_g) as sess:
pb_visual_writer = summary.FileWriter(log_dir)
pb_visual_writer.add_graph(sess.graph)
print("Model Imported. Visualize by running: "
"tensorboard --logdir={}".format(log_dir))