All Projects → yu4u → Convnet Drawer

yu4u / Convnet Drawer

Licence: mit
Python script for illustrating Convolutional Neural Networks (CNN) using Keras-like model definitions

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Convnet Drawer

Deep Mri Reconstruction
Deep Cascade of Convolutional Neural Networks for MR Image Reconstruction: Implementation & Demo
Stars: ✭ 204 (-60.47%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Tracking With Darkflow
Real-time people Multitracker using YOLO v2 and deep_sort with tensorflow
Stars: ✭ 515 (-0.19%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
3dmmasstn
MatConvNet implementation for incorporating a 3D Morphable Model (3DMM) into a Spatial Transformer Network (STN)
Stars: ✭ 218 (-57.75%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Vidaug
Effective Video Augmentation Techniques for Training Convolutional Neural Networks
Stars: ✭ 178 (-65.5%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Easy Deep Learning With Keras
Keras tutorial for beginners (using TF backend)
Stars: ✭ 367 (-28.88%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Hdltex
HDLTex: Hierarchical Deep Learning for Text Classification
Stars: ✭ 191 (-62.98%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Super Slomo
PyTorch implementation of Super SloMo by Jiang et al.
Stars: ✭ 2,714 (+425.97%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Self Driving Car
Udacity Self-Driving Car Engineer Nanodegree projects.
Stars: ✭ 2,103 (+307.56%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Fire Detection Cnn
real-time fire detection in video imagery using a convolutional neural network (deep learning) - from our ICIP 2018 paper (Dunnings / Breckon) + ICMLA 2019 paper (Samarth / Bhowmik / Breckon)
Stars: ✭ 340 (-34.11%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Tensorflow Image Detection
A generic image detection program that uses Google's Machine Learning library, Tensorflow and a pre-trained Deep Learning Convolutional Neural Network model called Inception.
Stars: ✭ 306 (-40.7%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Iresnet
Improved Residual Networks (https://arxiv.org/pdf/2004.04989.pdf)
Stars: ✭ 163 (-68.41%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
First Steps Towards Deep Learning
This is an open sourced book on deep learning.
Stars: ✭ 376 (-27.13%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Tf Adnet Tracking
Deep Object Tracking Implementation in Tensorflow for 'Action-Decision Networks for Visual Tracking with Deep Reinforcement Learning(CVPR 2017)'
Stars: ✭ 162 (-68.6%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Traffic Sign Detection
Traffic Sign Detection. Code for the paper entitled "Evaluation of deep neural networks for traffic sign detection systems".
Stars: ✭ 200 (-61.24%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Sign Language Interpreter Using Deep Learning
A sign language interpreter using live video feed from the camera.
Stars: ✭ 157 (-69.57%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Pyconv
Pyramidal Convolution: Rethinking Convolutional Neural Networks for Visual Recognition (https://arxiv.org/pdf/2006.11538.pdf)
Stars: ✭ 231 (-55.23%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Livianet
This repository contains the code of LiviaNET, a 3D fully convolutional neural network that was employed in our work: "3D fully convolutional networks for subcortical segmentation in MRI: A large-scale study"
Stars: ✭ 143 (-72.29%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Models Comparison.pytorch
Code for the paper Benchmark Analysis of Representative Deep Neural Network Architectures
Stars: ✭ 148 (-71.32%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Deepreg
Medical image registration using deep learning
Stars: ✭ 245 (-52.52%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks
Rmdl
RMDL: Random Multimodel Deep Learning for Classification
Stars: ✭ 375 (-27.33%)
Mutual labels:  deep-neural-networks, convolutional-neural-networks

ConvNet Drawer

Python script for illustrating Convolutional Neural Networks (CNN). Inspired by the draw_convnet project [1].

Models can be visualized via Keras-like (Sequential) model definitions. The result can be saved as SVG file or pptx file!

Requirements

python-pptx (if you want to save models as pptx)

pip install python-pptx

Keras (if you want to convert Keras sequential model)

pip install keras

matplotlib (if you want to save models via matplotlib)

pip install matplotlib

Usage

Write a script to define and save a model. An example of visualizing AlexNet [2] is as follows.

Write and save convnet_drawer.Model

from convnet_drawer import Model, Conv2D, MaxPooling2D, Flatten, Dense
from pptx_util import save_model_to_pptx
from matplotlib_util import save_model_to_file

model = Model(input_shape=(227, 227, 3))
model.add(Conv2D(96, (11, 11), (4, 4)))
model.add(MaxPooling2D((3, 3), strides=(2, 2)))
model.add(Conv2D(256, (5, 5), padding="same"))
model.add(MaxPooling2D((3, 3), strides=(2, 2)))
model.add(Conv2D(384, (3, 3), padding="same"))
model.add(Conv2D(384, (3, 3), padding="same"))
model.add(Conv2D(256, (3, 3), padding="same"))
model.add(MaxPooling2D((3, 3), strides=(2, 2)))
model.add(Flatten())
model.add(Dense(4096))
model.add(Dense(4096))
model.add(Dense(1000))

# save as svg file
model.save_fig("example.svg")

# save as pptx file
save_model_to_pptx(model, "example.pptx")

# save via matplotlib
save_model_to_file(model, "example.pdf")

Result:

The other examples can be found here.

Convert Keras sequential model

Keras sequential model can be converted to convnet_drawer.Model (thanks to @wakamezake). Only Conv2D, MaxPooling2D, GlobalAveragePooling2D, Flatten, Dense layers are supported for this conversion.

from keras_util import convert_drawer_model
from keras_models import AlexNet
from pptx_util import save_model_to_pptx
from matplotlib_util import save_model_to_file

# get Keras sequential model
keras_sequential_model = AlexNet.get_model()
model = convert_drawer_model(keras_sequential_model)

# save as svg file
model.save_fig("example.svg")

# save as pptx file
save_model_to_pptx(model, "example.pptx")

# save via matplotlib
save_model_to_file(model, "example.pdf")

Supported Layers

  • Conv2D
    • Conv2D(filters=None, kernel_size=None, strides=(1, 1), padding="valid")
    • e.g. Conv2D(96, (11, 11), (4, 4)))
  • Deconv2D
    • Deconv2D(filters=None, kernel_size=None, strides=(1, 1), padding="valid")
    • e.g. Deconv2D(256, (3, 3), (2, 2)))
  • MaxPooling2D, AveragePooling2D
    • MaxPooling2D(pool_size=(2, 2), strides=None, padding="valid")
    • e.g. MaxPooling2D((3, 3), strides=(2, 2))
    • If strides = None, stride is set to be pool_size.
  • GlobalAveragePooling2D
    • GlobalAveragePooling2D()
  • Flatten
    • Flatten()
  • Dense
    • Dense(units)
    • e.g. Dense(4096)

Visualization Parameters

Visualization Parameters can be found in config.py. Please adjust these parameters before model definition (see LeNet.py). The most important parameter is channel_scale = 3 / 5. This parameter rescale actual channel size c to c_ for visualization as:

c_ = math.pow(c, channel_scale)

If the maximum channel size is small (e.g. 512), please increase channel_scale.

Check how the other parameters works:

Default Values

theta = - math.pi / 6
ratio = 0.7
bounding_box_margin = 10
inter_layer_margin = 50
text_margin = 10
channel_scale = 3 / 5
text_size = 14
one_dim_width = 4
line_color_feature_map = (0, 0, 0)
line_color_layer = (0, 0, 255)
text_color_feature_map = (0, 0, 0)
text_color_layer = (0, 0, 0)

TODOs

  • [x] Implement padding option for Conv2D and Pooling layers.
  • [x] Add some effects to Dense layer (and Flatten / GlobalAveragePooling2D).
  • [ ] Automatically calibrate the scale of feature maps for better visibility.
  • [x] Move hard-coded parameters to a config file or options.
  • [x] Refactor Layer classes.
  • [x] Draw with matplotlib? for other formats. The model is now directly saved as a pptx file.

Results

LeNet

AlexNet

ZFNet

VGG16

AutoEncoder

AlexNet saved by matplotlib with plt.xkcd()

References

[1] https://github.com/gwding/draw_convnet

[2] A. Krizhevsky, I. Sutskever, and G. E. Hinton, "ImageNet Classification with Deep Convolutional Neural Networks," in Proc. of NIPS, 2012.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].