nnUNet icon indicating copy to clipboard operation
nnUNet copied to clipboard

network_architecture not available

Open annewiet opened this issue 2 years ago • 1 comments

Hi! I have trained my networks before, but I would like to see the network architecture. Thus, I installed hiddenlayer and ipython and graphviz. When I restart the training of a fold, a file network_architecture is created. However, it is not a pdf but just a 'file'. How do I get a figure of the architecture?

annewiet avatar May 30 '22 01:05 annewiet

Hey it could be that there is still some error message. Check the stdout of your script for any error messages (we just skip ahead if exporting the pdf does not work for some reason as this is a non-critical component of nnU-Net)

FabianIsensee avatar Aug 23 '22 11:08 FabianIsensee

Hi! I was facing the same issue, where the generated network architecture file was not a pdf. I fixed it by replacing _optimize_trace with _optimize_graph inside pytorch_builder.py [Line 71] file inside the installed hiddenlayer package. Followed the answer in this thread: https://stackoverflow.com/questions/74394812/cannot-plot-model-graph-with-pytorch-hiddenlayer-module-torch-onnx-has-no-at.

@FabianIsensee should we add this fix to nnUNet permanently?

Mohinta2892 avatar Feb 18 '23 12:02 Mohinta2892

If you are willing to do a PR about this then I can merge it :+1:

FabianIsensee avatar Feb 27 '23 13:02 FabianIsensee

Hi @hep-raidium,

Do you know which torch version you are using? Also do you have torchvision installed?

Hi,

I had the same issue and dealt with it with what @Mohinta2892 offered. Unfortunately, it triggers a new error for creating the network architecture :

'torch._C.Node' object is not subscriptable

Do you know what I can do ?

Mohinta2892 avatar Apr 05 '23 15:04 Mohinta2892

Hey,

found the solution. After doing what @Mohinta2892 suggested I then solved the 'torch._C.Node' error with replacing the line "params = ..... " (line n° 85 approximately in PyTorch_builder.py) by : "params = {k: getattr(torch_node, torch_node.kindOf(k))(k) for k in torch_node.attributeNames()}" (cf https://github.com/tianyic/only_train_once/issues/6 ) and it worked :) I was using '2.0.0+cu117' torch version :) Best,

hep-raidium avatar Apr 07 '23 09:04 hep-raidium

I had the same problem and followed the solutions mentioned above, but since the server didn't have Graphviz installed, it returned the following error message

2023-04-07 16:59:58.575276: Unable to plot network architecture:
2023-04-07 16:59:58.611060: failed to execute PosixPath('dot'), make sure the Graphviz executables are on your systems' PATH

However, in the nnunet_results folder "/results/Dataset032_BraTS2018/nnUNetTrainer__nnUNetPlans__3d_fullres/fold_0/network_architecture", there was a "network_architecture" file (probably a Dot file) saved with no extension (I don't know which line of code saved this). Therefore, I was able to visualize the network architecture, in the end, using my local computer.
It would be useful if nnunetv2 could save the network architecture Dot file even though hiddenlayer no longer works.

LouisDo2108 avatar Apr 07 '23 17:04 LouisDo2108

Hi @FabianIsensee,

Pull request submitted with the fixes.

Mohinta2892 avatar Apr 19 '23 16:04 Mohinta2892

PR is merged - it should work now

FabianIsensee avatar May 02 '23 09:05 FabianIsensee

@LouisDo2108 I had the same issue and was able to resolve it by running 'conda install python-graphviz'.

Ignareo avatar May 17 '23 05:05 Ignareo

@LouisDo2108 I had the same issue and was able to resolve it by running 'conda install python-graphviz'.

That's helpful, thanks!

LIKP0 avatar Oct 04 '23 10:10 LIKP0