This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
model_js | ||
node_modules |
This file contains 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
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") |