Skip to content

Instantly share code, notes, and snippets.

@fsausset
fsausset / keras2android.py
Created March 31, 2017 14:43
Export a Keras model to a tensorflow .pb file with embedded weights to use on Android.
from keras.models import Sequential
from keras.models import model_from_json
from keras import backend as K
import tensorflow as tf
from tensorflow.python.tools import freeze_graph
import os
# Load existing model.
with open("model.json",'r') as f:
modelJSON = f.read()