Last active
March 7, 2018 13:17
-
-
Save bholota/f67bcc9b51c079486f9c2322e53f8861 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import tensorflow as tf | |
# manually put back imported modules - bug? | |
import tempfile | |
import subprocess | |
tf.contrib.lite.tempfile = tempfile | |
tf.contrib.lite.subprocess = subprocess | |
with tf.name_scope("inputs"): | |
X = tf.placeholder(tf.float32, [2], name="X-input") | |
with tf.name_scope("outputs"): | |
Y = tf.add(X[0], X[1], name="Y-output") | |
with tf.Session() as sess: | |
sess.run(tf.global_variables_initializer()) | |
tflite_model = tf.contrib.lite.toco_convert(sess.graph_def, [X], [Y]) | |
with open('fm.lite', "wb") as f: | |
f.write(tflite_model) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting
java.lang.IllegalArgumentException: Invalid handle to Interpreter.
when trying to use fm.lite in android app.Android code:
It's working properly with some samples found in github (after altering input/output size).
I also tried to freeze graph, save it as pb and then convert with toco:
toco --input_file=frozen_model.pb --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE --output_file=frozen_model.lite --inference_type=FLOAT --input_arrays=inputs/X-input --output_arrays=outputs/Y-output --input_shapes=2 --output_shapes=1
Unfortunately same error is thrown.