lutzroeder / netron

Visualizer for neural network, deep learning and machine learning models
https://netron.app
MIT License
26.82k stars 2.7k forks source link

Export image via command line #162

Closed phadjido closed 2 years ago

phadjido commented 5 years ago

The visualization results of netron are really great. This is also true for the exported images. So, I am wondering if it will be possible: a) to export the network to a png/svg file using the python http server b) to export the network directly to a file by using a command line argument (ideally without starting a server or doing this within a python script)

lutzroeder commented 5 years ago

The layout and visualization is done in the browser in JavaScript. The rendering is done on the client, not the Python server.

ahmedhosny commented 5 years ago

@lutzroeder I wonder if there is a way to serve the model statically from a html+js bundle. We want to keep the model viewers running without have to run the server. I guess one way is to export the SVG and enable panning, albeit without the interactivity. When doing a "save as" from the browser, the resultant html does display the components in the graph but without text - before giving this expected error: Error while requesting model. 0 test

rinosh1989 commented 3 years ago

@lutzroeder It would be great if you could implement exporting of the model as png/svg from command line.

sergei-mironov commented 3 years ago

Hi I experienced the similar problem with Altair library for doing scientific plots, which also relies on web-client for rendering. Static PNG export is solved there in a separate project Altair-saver. It works fine, but knowing details causes a kind of facepalm: they use Seleneum (or optionally Node-js) to capture the picture from web-client. Installing those dependencies is a pain, but I think that it is better than nothing. Indeed, PNG-export is very important feature. +1 from me to the above post..

andrewcstewart commented 10 months ago

Hi @lutzroeder - I see a lot of issues pointing back to this issue, but while the issue history here says its complete it looks like maybe you just closed it as a rejection of the feature request? I'd say it's of course totally valid if you think it's not a reasonable feature request or you simply don't want to do it, etc, but imho it would probably at least be useful to leave a note to that effect on this issue? (maybe even add a label like "wont do")

For what it's worth, I think an enabling step towards these types of feature requests could be to add support for programmatic image export via a REST API endpoint from the server, if that's at all possible in this Electron framework. Basically a REST endpoint that does the same thing as clicking the "Export to PNG/SVG" option in the UI. If that existed, then users would be able to programmatically export images by starting a headless server and hitting that API endpoint. Just a thought.

lutzroeder commented 10 months ago

@andrewcstewart see ^^^. The app runs in the browser and is rendering client side. There is no server. There might be ways to implement this feature by running a browser head in Python. Feel free to investigate, submit a pull request and sign up for testing and maintaining this feature. Ideally this should be done in a way that doesn't add more dependencies, works on all supported platforms and not add complexity to the architecture. "Closed" is to indicate that nobody is actively working on this.

raphael-prevost commented 9 months ago

Hi! I have just hacked a way of exporting the graphs as png/svg files via Python or command line (it works by starting a netron server, a browser and simulating the clicks on the right HTML elements). Might be a bit fragile but it does the job.

Since there seems to be some interest for a solution, we have put it in a Python module available here: https://github.com/raphael-prevost/netron-export