Clone the repository on your local machine:
$ git clone https://github.com/tonio73/dnnviewer.git
For local development, the entry point is the file dnnviewer.py
in the root directory.
Model ZOO is in
$ dnnviewer.py --model-keras dnnviewer-data/models/MNIST_dense128.h5 --test-dataset mnist
The application is based on Dash for the user interface management (which is generating ReactJs components), and Plotly for the data visualization.
Code is separated in two branches:
- The Graphical representation
- Adapters to read existing models, currently only supporting Keras
Top level class it the dnnviewer.Grapher. It holds a collection of layers based on the base class dnnviewer.layers.AbstractLayer.AbstractLayer
Within dnnviewer.bridge
is the code to load a DNN model in Keras and extract the DNN topology, weights, compute the gradients and activations
$ dnnviewer --model-keras dnnviewer-data/models/CIFAR-10_CNN5-Reg.tf --test-dataset cifar10
$ dnnviewer --model-keras dnnviewer-data/models/MNIST_LeNet60.h5 --test-dataset mnist
$ dnnviewer --sequence-keras "dnnviewer-data/models/FashionMNIST_checkpoints/model1_{epoch}" --test-dataset fashion-mnist
--debug
is launching the Dash application in debug mode:
- The application is automatically reloaded when the code is saved
- The Dash debug tools are shown on screen (errors, callback dep graph)
--log-level DEBUG
to get the debug messages displayed in the console log
- Code is PEP8 compliant, thanks to flake8 and Intellij for watching
- There are a few pytest unit tests in
unittests/
Logging is done using the standard Python logs
import logging
#...
def my_smart_function():
logger = logging.getLogger(__name__)
logger.error('Not smart enough')
Exceptions shall be used whenever the code execution shall be interrupted
Exceptions within the bridge package are based on the exception class bridge.AbstractModelSequence.ModelError
Dash callbacks are safeguarded, no need to add the try-except
around the callback code.
To prevent update, the exception to raise is dash.exceptions.PreventUpdate
From project root directory:
$ python -m pytest
or, simpler:
$ make tests
$ make lint
First increase the version number in setup.py
Then:
$ make package
$ make package_upload
Pypi.org credentials required
To force reinstall of the package (in case of minor version increase), do not forget the --no-deps:
$ pip install --force-reinstall --no-deps dnnviewer