Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

save problem #24

Open
HiYellowC opened this issue Nov 22, 2018 · 5 comments
Open

save problem #24

HiYellowC opened this issue Nov 22, 2018 · 5 comments

Comments

@HiYellowC
Copy link

how can I save the output as png or jpg?

@Honzys
Copy link

Honzys commented Dec 10, 2018

Use:

dot.format = format
dot.render(filename)

where

@soulslicer
Copy link

I tried to do that and the image I get is nonetype:

            disp = model(imgL,imgR)

            dot = make_dot(disp) 
            print(dot)

            dot.render("test.png")

@kamalravi
Copy link

kamalravi commented Jan 27, 2020

@soulslicer Try like this

x = torch.zeros(1, 3, 224, 224, dtype=torch.float, requires_grad=False)
out = model(x)
dot=make_dot(out)
print(dot)
dot.format = 'png'
dot.render("filename")

where

  • x is your input
  • model is your deep model (e.g. resnet)

You will get a "filename.png" image file. You can specify different format like 'svg' if you need.

@ucalyptus
Copy link

@kamalravi it gives
----> 7 dot.format("png")
8 dot.render("danet_model")

TypeError: 'str' object is not callable

@AruniRC
Copy link

AruniRC commented May 1, 2020

I think a full example for saving might be helpful, especially for those not immediately familiar with graphviz.

dot = torchviz.make_dot(y.mean(), params=dict(model.named_parameters()))
dot.format = 'png'
dot.render('torchviz-sample')

And the image is saved under the current working directory as torchviz-sample.png.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants