# nnViewer
**nnViewer** is a Python library designed to provide an intuitive GUI for visualizing the structure and flow of a `torch.nn.Module`. Whether you're debugging or exploring complex neural networks, nnViewer makes it easier to understand your models.
## Installation
Install the library via pip:
```bash
pip install nnViewer
```
## Quick Start
Here's an example of how to use nnViewer with a Hugging Face model:
```python
from transformers import AutoImageProcessor, AutoModel
from PIL import Image
import requests
from nnViewer.back.graph_initializer import wrap_model
from nnViewer.front.gui import run_gui
# Load an image
url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)
# Load the model and processor
processor = AutoImageProcessor.from_pretrained('facebook/dinov2-large')
model = AutoModel.from_pretrained('facebook/dinov2-large')
# Prepare the inputs
inputs = processor(images=image, return_tensors="pt")
# Initialize the graph
graph_init = wrap_model(model)
# Run the model to populate the graph
model(**inputs)
# Launch the GUI
run_gui(graph_init.graph)
```
## Overview
### `wrap_model(model: nn.Module) -> GraphInitializer`
Wraps a `torch.nn.Module` to initialize the computational graph for visualization.
### `run_gui(graph)`
Launches the GUI to display the computational graph.
## Contributing
Contributions are welcome! If you find any issues or have feature requests, feel free to open a GitHub issue or submit a pull request.
## License
This project is licensed under the MIT License. See the `LICENSE` file for more details.
Raw data
{
"_id": null,
"home_page": "https://github.com/PBDESG/nnViewer",
"name": "nnViewer",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "neural networks, visualization, torch, PyQt5, graphviz",
"author": "PBDESG",
"author_email": "PBDESG <pbdesg@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/43/3e/832954027eed00c9ecbab3bb3048cbf1f3e5831b108637ec00eb56828edc/nnviewer-0.1.3.tar.gz",
"platform": null,
"description": "# nnViewer\n\n**nnViewer** is a Python library designed to provide an intuitive GUI for visualizing the structure and flow of a `torch.nn.Module`. Whether you're debugging or exploring complex neural networks, nnViewer makes it easier to understand your models.\n\n## Installation\n\nInstall the library via pip:\n\n```bash\npip install nnViewer\n```\n\n## Quick Start\n\nHere's an example of how to use nnViewer with a Hugging Face model:\n\n```python\nfrom transformers import AutoImageProcessor, AutoModel\nfrom PIL import Image\nimport requests\n\nfrom nnViewer.back.graph_initializer import wrap_model\nfrom nnViewer.front.gui import run_gui\n\n# Load an image\nurl = 'http://images.cocodataset.org/val2017/000000039769.jpg'\nimage = Image.open(requests.get(url, stream=True).raw)\n\n# Load the model and processor\nprocessor = AutoImageProcessor.from_pretrained('facebook/dinov2-large')\nmodel = AutoModel.from_pretrained('facebook/dinov2-large')\n\n# Prepare the inputs\ninputs = processor(images=image, return_tensors=\"pt\")\n\n# Initialize the graph\ngraph_init = wrap_model(model)\n\n# Run the model to populate the graph\nmodel(**inputs)\n\n# Launch the GUI\nrun_gui(graph_init.graph)\n```\n\n## Overview\n\n### `wrap_model(model: nn.Module) -> GraphInitializer`\nWraps a `torch.nn.Module` to initialize the computational graph for visualization.\n\n### `run_gui(graph)`\nLaunches the GUI to display the computational graph.\n\n## Contributing\n\nContributions are welcome! If you find any issues or have feature requests, feel free to open a GitHub issue or submit a pull request.\n\n## License\n\nThis project is licensed under the MIT License. See the `LICENSE` file for more details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A neural network visualization tool",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/PBDESG/nnViewer"
},
"split_keywords": [
"neural networks",
" visualization",
" torch",
" pyqt5",
" graphviz"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bbd56aeb780e6caeabd5fd189250462192c6ffb797cef6b327f700b69c81932e",
"md5": "f7e87a11b2ef3e91ee042b0c8d53218e",
"sha256": "e5fc9b8cb5adcd64629738946a74c5cef4b7a4d83de426fcd27d4cced7dadf50"
},
"downloads": -1,
"filename": "nnViewer-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f7e87a11b2ef3e91ee042b0c8d53218e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 24813,
"upload_time": "2025-01-22T13:35:56",
"upload_time_iso_8601": "2025-01-22T13:35:56.439449Z",
"url": "https://files.pythonhosted.org/packages/bb/d5/6aeb780e6caeabd5fd189250462192c6ffb797cef6b327f700b69c81932e/nnViewer-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "433e832954027eed00c9ecbab3bb3048cbf1f3e5831b108637ec00eb56828edc",
"md5": "b9e027f6d465345c9d1ae107bdefc763",
"sha256": "542c77b1546d4ddd6ebf94017d94248584ef2ee36de2d8967784dfd63a9c2295"
},
"downloads": -1,
"filename": "nnviewer-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "b9e027f6d465345c9d1ae107bdefc763",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 22313,
"upload_time": "2025-01-22T13:35:58",
"upload_time_iso_8601": "2025-01-22T13:35:58.663927Z",
"url": "https://files.pythonhosted.org/packages/43/3e/832954027eed00c9ecbab3bb3048cbf1f3e5831b108637ec00eb56828edc/nnviewer-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-22 13:35:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "PBDESG",
"github_project": "nnViewer",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "nnviewer"
}