Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
added model conversion script.
Browse files Browse the repository at this point in the history
  • Loading branch information
code2k13 committed Nov 4, 2022
1 parent d3fbf20 commit f30121b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

model_js
node_modules
19 changes: 19 additions & 0 deletions convert_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import tensorflow as tf
import model
import tensorflowjs as tfjs

G2 = model.Generator()
G2.trainable = False
G2.load_weights("weights/weights")

# Convert the model
converter = tf.lite.TFLiteConverter.from_keras_model(G2) # path to the SavedModel directory
#converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_LATENCY]
converter.optimizations = [tf.lite.Optimize.OPTIMIZE_FOR_SIZE]
tflite_model = converter.convert()

# Save the model.
with open('model.tflite', 'wb') as f:
f.write(tflite_model)

tfjs.converters.save_keras_model(G2, "model_js")

0 comments on commit f30121b

Please sign in to comment.