All Projects → dezmoanded → vrn-torch-to-keras

dezmoanded / vrn-torch-to-keras

Licence: other
Transfer pre-trained VRN model from torch to Keras/Tensorflow

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to vrn-torch-to-keras

Artificial Intelligence Deep Learning Machine Learning Tutorials
A comprehensive list of Deep Learning / Artificial Intelligence and Machine Learning tutorials - rapidly expanding into areas of AI/Deep Learning / Machine Vision / NLP and industry specific areas such as Climate / Energy, Automotives, Retail, Pharma, Medicine, Healthcare, Policy, Ethics and more.
Stars: ✭ 2,966 (+4607.94%)
Mutual labels:  torch
GTAV-Self-driving-car
Self driving car in GTAV with Deep Learning
Stars: ✭ 15 (-76.19%)
Mutual labels:  keras-models
Video2Language
Generating video descriptions using deep learning in Keras
Stars: ✭ 22 (-65.08%)
Mutual labels:  keras-models
Facial emotion recognition using Keras
I have used FER2013 dataset and try to build the Facial emotion recognition using Keras
Stars: ✭ 16 (-74.6%)
Mutual labels:  keras-models
emusic net
Neural network to classify certain styles of Electronic music
Stars: ✭ 22 (-65.08%)
Mutual labels:  keras-models
image-background-remove-tool
✂️ Automated high-quality background removal framework for an image using neural networks. ✂️
Stars: ✭ 767 (+1117.46%)
Mutual labels:  torch
Floorplantransformation
Raster-to-Vector: Revisiting Floorplan Transformation
Stars: ✭ 243 (+285.71%)
Mutual labels:  torch
ALIGNet
code to train a neural network to align pairs of shapes without needing ground truth warps for supervision
Stars: ✭ 58 (-7.94%)
Mutual labels:  torch
deepgenres.torch
Predict the genre of a song using the Torch deep learning library
Stars: ✭ 18 (-71.43%)
Mutual labels:  torch
inpainting FRRN
Progressive Image Inpainting (Kolmogorov Team solution for Huawei Hackathon 2019 summer)
Stars: ✭ 30 (-52.38%)
Mutual labels:  torch
graftr
graftr: an interactive shell to view and edit PyTorch checkpoints.
Stars: ✭ 89 (+41.27%)
Mutual labels:  torch
ThArrays.jl
A Julia interface for PyTorch's C++ backend, focusing on Tensor, AD, and JIT
Stars: ✭ 23 (-63.49%)
Mutual labels:  torch
keras-aquarium
a small collection of models implemented in keras, including matrix factorization(recommendation system), topic modeling, text classification, etc. Runs on tensorflow.
Stars: ✭ 14 (-77.78%)
Mutual labels:  keras-models
multiclass-semantic-segmentation
Experiments with UNET/FPN models and cityscapes/kitti datasets [Pytorch]
Stars: ✭ 96 (+52.38%)
Mutual labels:  torch
Captcha-Cracking
Crack number and Chinese captcha with both traditional and deep learning methods, based on Torch and python.
Stars: ✭ 35 (-44.44%)
Mutual labels:  torch
Pixeldtgan
A torch implementation of "Pixel-Level Domain Transfer"
Stars: ✭ 248 (+293.65%)
Mutual labels:  torch
yann
Yet Another Neural Network Library 🤔
Stars: ✭ 26 (-58.73%)
Mutual labels:  torch
open-solution-cdiscount-starter
Open solution to the Cdiscount’s Image Classification Challenge
Stars: ✭ 20 (-68.25%)
Mutual labels:  keras-models
hypnettorch
Package for working with hypernetworks in PyTorch.
Stars: ✭ 66 (+4.76%)
Mutual labels:  torch
eccv16 attr2img
Torch Implemention of ECCV'16 paper: Attribute2Image
Stars: ✭ 93 (+47.62%)
Mutual labels:  torch

vrn-torch-to-keras

Transfer pre-trained VRN model from torch to Keras

Source of original model

"Large Pose 3D Face Reconstruction from a Single Image via Direct Volumetric CNN Regression" https://github.com/AaronJackson/vrn
Download: http://cs.nott.ac.uk/~psxasj/download.php?file=vrn-unguided.t7

Script used to parse t7 file

https://github.com/bshillingford/python-torchfile

Resulting Keras model

https://drive.google.com/file/d/1oh8Zpe4wh00iXcm8ztRsi5ZL6GMkHdjj/view?usp=sharing

Usage

from keras.models import load_model
import custom_layers
custom_objects = {
    'Conv': custom_layers.Conv,
    'BatchNorm': custom_layers.BatchNorm,
    'UpSamplingBilinear': custom_layers.UpSamplingBilinear
}
model = load_model('vrn-unguided-keras.h5', custom_objects=custom_objects)

Input is 3 x 192 x 192 (channels first)
You will need to install h5py.

See Example-Usage.ipynb for a full example using pyplot and visvis

Tensorflow model

https://drive.google.com/file/d/1THX-x6TR8Qg7zFfaFXU3cFd9PCZp22IY/view?usp=sharing

from tensorflow.core.framework import graph_pb2

with open('vrn-tensorflow.pb', "rb") as f:
    output_graph_def = graph_pb2.GraphDef()
    output_graph_def.ParseFromString(f.read())
    _ = tf.import_graph_def(output_graph_def, name="")

x = sess.graph.get_tensor_by_name('input_1_1:0')
y = sess.graph.get_tensor_by_name('activation_274_1/Sigmoid:0')

img = cv2.imread('joey.jpg')
img = cv2.resize(img, (192, 192))
b,g,r = cv2.split(img)
img = cv2.merge([r,g,b])
img = np.swapaxes(img, 2, 0)
img = np.swapaxes(img, 2, 1)
img = np.array([img])

pred = sess.run(y, feed_dict={x: img})

visvis render

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].