Keras Deep Learning with Apple’s CoreMLTools on iOS 11 – Part 1

kerasxcode

This is a basic example of train and use a basic Keras neural network model (XOR) on iPhone using Apple’s coremltools on iOS11. Note that showing the integration starting from a Keras model to having it running in the iOS app is the main point and not the particular choice of model, in principle a similar approach could be used for any kind of Deep Learning model, e.g. generator part of Generative Adversarial Networks, a Recurrent Neural Network (or LSTM) or a Convolutional Neural Network.

For easy portability I chose to run the Keras part inside docker (i.e. could e.g. use nvidia-docker for a larger model that would need a GPU to train e.g. in the cloud or on a desktop or a powerful laptop). The current choice of Keras backend was TensorFlow, but believe it should also work for other backends (e.g. CNTK, Theano or MXNet). The code for this blog post is available at github.com/atveit/keras2ios

Best regards,

Amund Tveit

1. Building and training Keras Model for XOR problem – PYTHON

1.1 Training data for XOR

1.2 Keras XOR Neural Network Model

1.3 Train the Keras model with Stochastic Gradient Descent (SGD)

1.4 Use Apple’s coreml tool to convert the Keras model to coreml model

2. Using the converted Keras model on iPhone – SWIFT

2.1 Create new Xcode Swift project and add keras_model.mlmodel

kerasxcode

2.2 Inspect keras_model.mlmodel by clicking on it in xcode

mlmodelinspect

2.3 Update ViewController.swift with prediction function

2.4 Run app with Keras model on iPhone and look at debug output

run output

0 xor 0 = 1 xor 1 = 0 (if rounding down), and 1 xor 0 = 0 xor 1 = 1 (if rounding up)

LGTM!

Sign up for Deep Learning newsletter!


Continue Reading

Deep Learning for Image Super-Resolution (Scale Up)

superresolution

Scaling down images is a craft, scaling up images is an art

Since in the scaling down to a lower resolution you typically need to remove pixels, but in the case of scaling up you need to invent new pixels. But some Deep Learning models with Convolutional Neural Networks (and frequently Deconvolutional layers) has shown successful to scale up images, this is called Image Super-Resolution. These models are typically trained by taking high resolution images and reducing them to lower resolution and then train in the opposite way. Partially related: Recommend also checking out Odeon et. al’s Distill.pub’s publication: Deconvolution and Checkerboard Artifacts that goes into more detail about the one the core operators used in Image Super-Resolution.

Blog post Illustration Source: Eric Esteve’s 2013 article: Super Resolution bring high end camera image quality to smartphone.

Best regards,

Amund Tveit

Year  Title Author
2017   GUN: Gradual Upsampling Network for single image super-resolution  Y Zhao, R Wang, W Dong, W Jia, J Yang, X Liu, W Gao
2017   Dual Recovery Network with Online Compensation for Image Super-Resolution  S Xia, W Yang, T Zhao, J Liu
2017   A New Single Image Super-resolution Method Based on the Infinite Mixture Model  P Cheng, Y Qiu, X Wang, K Zhao
2017   Underwater Image Super-resolution by Descattering and Fusion  H Lu, Y Li, S Nakashima, H Kim, S Serikawa
2017   Single Image Super-Resolution with a Parameter Economic Residual-Like Convolutional Neural Network  Z Yang, K Zhang, Y Liang, J Wang
2017   Single Image Super-Resolution via Adaptive Transform-Based Nonlocal Self-Similarity Modeling and Learning-Based Gradient Regularization  H Chen, X He, L Qing, Q Teng
2017   Ensemble Based Deep Networks for Image Super-Resolution  Z Huang, L Wang, Y Gong, C Pan
2017   Single Image Super-Resolution Using Multi-Scale Convolutional Neural Network  X Jia, X Xu, B Cai, K Guo
2017   Hyperspectral image super-resolution using deep convolutional neural network  Y Li, J Hu, X Zhao, W Xie, JJ Li
2016   Research on the Natural Image Super-Resolution Reconstruction Algorithm based on Compressive Perception Theory and Deep Learning Model  G Duan, W Hu, J Wang
2016   Image super-resolution with multi-channel convolutional neural networks  Y Kato, S Ohtani, N Kuroki, T Hirose, M Numa
2016   Image super-resolution reconstruction via RBM-based joint dictionary learning and sparse representation  Z Zhang, A Liu, Q Lei
2016   End-to-End Image Super-Resolution via Deep and Shallow Convolutional Networks  Y Wang, L Wang, H Wang, P Li
2016   Single image super-resolution using regularization of non-local steering kernel regression  K Zhang, X Gao, J Li, H Xia
2016   Single image super-resolution via blind blurring estimation and anchored space mapping  X Zhao, Y Wu, J Tian, H Zhang
2016   A Versatile Sparse Representation Based Post-Processing Method for Improving Image Super-Resolution  J Yang, J Guo, H Chao
2016   Robust Single Image Super-Resolution via Deep Networks with Sparse Prior.  D Liu, Z Wang, B Wen, J Yang, W Han, T Huang
2016   EnhanceNet: Single Image Super-Resolution through Automated Texture Synthesis  MSM Sajjadi, B Schölkopf, M Hirsch
2016   Is Image Super-resolution Helpful for Other Vision Tasks?  D Dai, Y Wang, Y Chen, L Van Gool
2016   Cluster-Based Image Super-resolution via Jointly Low-rank and Sparse Representation  N Han, Z Song, Y Li
2016   Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network  C Ledig, L Theis, F Huszar, J Caballero, A Aitken
2016   Image super-resolution using non-local Gaussian process regression  H Wang, X Gao, K Zhang, J Li
2016   A hybrid wavelet convolution network with sparse-coding for image super-resolution  X Gao, H Xiong
2016   Amortised MAP Inference for Image Super-resolution  CK Sønderby, J Caballero, L Theis, W Shi, F Huszár
2016   X-Ray fluorescence image super-resolution using dictionary learning  Q Dai, E Pouyet, O Cossairt, M Walton, F Casadio
2016   Image super-resolution based on convolution neural networks using multi-channel input  GY Youm, SH Bae, M Kim
2016   Deep Edge Guided Recurrent Residual Learning for Image Super-Resolution  W Yang, J Feng, J Yang, F Zhao, J Liu, Z Guo, S Yan
2016   Image Super-Resolution by PSOSEN of Local Receptive Fields Based Extreme Learning Machine  Y Song, B He, Y Shen, R Nian, T Yan
2016   Incorporating Image Priors with Deep Convolutional Neural Networks for Image Super-Resolution  Y Liang, J Wang, S Zhou, Y Gong, N Zheng
2015   Single Image Super-Resolution Via Bm3D Sparse Coding  K Egiazarian, V Katkovnik
2015   Learning a Deep Convolutional Network for Light-Field Image Super-Resolution  Y Yoon, HG Jeon, D Yoo, JY Lee, I Kweon
2015   Single Image Super-Resolution via Image Smoothing  Z Liu, Q Huang, J Li, Q Wang
2015   Deeply Improved Sparse Coding for Image Super-Resolution  Z Wang, D Liu, J Yang, W Han, T Huang
2015   Conditioned Regression Models for Non-Blind Single Image Super-Resolution  GRSSM Rüther, H Bischof
2015   How Useful Is Image Super-resolution to Other Vision Tasks?  D Dai, Y Wang, Y Chen, L Van Gool
2015   Learning Hierarchical Decision Trees for Single Image Super-Resolution  JJ Huang, WC Siu
2015   Single image super-resolution by approximated Heaviside functions  LJ Deng, W Guo, TZ Huang
2015   Jointly Optimized Regressors for Image Super-resolution  D Dai, R Timofte, L Van Gool
2015   Single Image Super-Resolution via Internal Gradient Similarity  Y Xian, Y Tian
2015   Image Super-Resolution Using Deep Convolutional Networks  C Dong, CC Loy, K He, X Tang
2015   Coupled Deep Autoencoder for Single Image Super-Resolution  K Zeng, J Yu, R Wang, C Li, D Tao
2015   Single Image Super-Resolution Using Maximizing Self-Similarity Prior  J Li, Y Wu, X Luo
2015   Accurate Image Super-Resolution Using Very Deep Convolutional Networks  J Kim, JK Lee, KM Lee
2015   Deeply-Recursive Convolutional Network for Image Super-Resolution  J Kim, JK Lee, KM Lee
2015   Single Face Image Super-Resolution via Solo Dictionary Learning  F Juefei
2014   Single image super-resolution via L0 image smoothing  Z Liu, Q Huang, J Li, Q Wang
Continue Reading

Deep Learning for Acoustic Modelling

acousticmodelling

This blog post has an overview papers related to acoustic modelling primarily for speech recognition but also speech generation (synthesis). See also ai.amundtveit.com/keyword/acoustic for a broader set of (at the time of writing 73) recent Deep Learning papers related to acoustics for speech recognition and other applications of acoustics.

Acoustic Modelling is described in Wikipedia as: “An acoustic model is used in Automatic Speech Recognition to represent the relationship between an audio signal and the phonemes or other linguistic units that make up speech. The model is learned from a set of audio recordings and their corresponding transcripts”. 

Blog Post Illustration Photo Source: Professor Mark Gales‘ (University of Cambridge) 2009 presentation Acoustic Modelling for Speech Recognition: Hidden Markov Models and Beyond?

Best regards,

Amund Tveit

Year  Title Author
2017   Investigation on acoustic modeling with different phoneme set for continuous Lhasa Tibetan recognition based on DNN method  H Wang, K Khyuru, J Li, G Li, J Dang, L Huang
2017   Personalized Acoustic Modeling By Weakly Supervised Multi-Task Deep Learning Using Acoustic Tokens  CK Wei, CT Chung, HY Lee, LS Lee
2017   I-vector estimation as auxiliary task for multi-task learning based acoustic modeling for automatic speech recognition  G Pironkov, S Dupont, T Dutoit
2016   Graph-based Semi-Supervised Learning in Acoustic Modeling for Automatic Speech Recognition  Y Liu
2016   A Comprehensive Study of Deep Bidirectional LSTM RNNs for Acoustic Modeling in Speech Recognition  A Zeyer, P Doetsch, P Voigtlaender, R Schlüter, H Ney
2016   Improvements in IITG Assamese Spoken Query System: Background Noise Suppression and Alternate Acoustic Modeling  S Shahnawazuddin, D Thotappa, A Dey, S Imani
2016   DNN-Based Acoustic Modeling for Russian Speech Recognition Using Kaldi  I Kipyatkova, A Karpov
2015   Doubly Hierarchical Dirichlet Process Hmm For Acoustic Modeling  AHHN Torbati, J Picone
2015   Deep Learning for Acoustic Modeling in Parametric Speech Generation: A systematic review of existing techniques and future trends  ZH Ling, SY Kang, H Zen, A Senior, M Schuster
2015   Acoustic Modeling In Statistical Parametric Speech Synthesis–From Hmm To Lstm-Rnn  H Zen
2015   Acoustic Modeling of Bangla Words using Deep Belief Network  M Ahmed, PC Shill, K Islam, MAH Akhand
2015   Unified Acoustic Modeling using Deep Conditional Random Fields  Y Hifny
2015   Exploiting Low-Dimensional Structures To Enhance Dnn Based Acoustic Modeling In Speech Recognition  P Dighe, G Luyet, A Asaei, H Bourlard
2015   Ensemble Acoustic Modeling for CD-DNN-HMM Using Random Forests of Phonetic Decision Trees  T Zhao, Y Zhao, X Chen
2015   Deep Neural Networks for Acoustic Modeling  V from Embeds, G Hinton, L Deng, D Yu, G Dahl
2015   Integrating Articulatory Data in Deep Neural Network-based Acoustic Modeling  L Badino, C Canevari, L Fadiga, G Metta
2015   Deep learning in acoustic modeling for Automatic Speech Recognition and Understanding-an overview  I Gavat, D Militaru
Continue Reading