tensorflow / tensorboard

TensorFlow's Visualization Toolkit
Apache License 2.0
6.73k stars 1.66k forks source link

add_graph with .pt and failed with 'dict' object has no attribute 'param_init_net' #6720

Open OrdinaryChen opened 10 months ago

OrdinaryChen commented 10 months ago

I run from torch.utils.tensorboard import SummaryWriter model_path = 'yolov8n-seg.pt' loaded_model = torch.load(model_path) writer = SummaryWriter('tensor_vis') init_img = torch.zeros((1,3,640,640),device='cuda') writer.add_graph(loaded_model) writer.close()

but raise an error:

Traceback (most recent call last): File "/root/docker_mapping/CYZ/yolov8/demo/demo.py", line 21, in writer.add_graph(loaded_model) File "/opt/conda/envs/yolov8/lib/python3.8/site-packages/torch/utils/tensorboard/writer.py", line 742, in add_graph current_graph = model_to_graph_def(model) File "/opt/conda/envs/yolov8/lib/python3.8/site-packages/torch/utils/tensorboard/_caffe2_graph.py", line 770, in model_to_graph_def nets = [model.param_init_net, model.net] AttributeError: 'dict' object has no attribute 'param_init_net'

why what should I do now

OrdinaryChen commented 10 months ago

this is code

from torch.utils.tensorboard import SummaryWriter model_path = 'yolov8n-seg.pt' loaded_model = torch.load(model_path) writer = SummaryWriter('tensor_vis') init_img = torch.zeros((1,3,640,640),device='cuda') writer.add_graph(loaded_model,init_img ) writer.close()

yatbear commented 10 months ago

Hi @OrdinaryChen,

This is seems to be an issue either within PyTorch library or related to how the PyTorch API is being used. Can you please move the question to https://github.com/pytorch/pytorch/issues?