File tree 1 file changed +12
-10
lines changed
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 1
1
import tensorflow as tf
2
2
import os
3
3
4
+
4
5
def convert_to_tflite ():
5
6
# Load the SavedModel
6
- model = tf .saved_model .load (' chattts_tf' )
7
-
7
+ model = tf .saved_model .load (" chattts_tf" )
8
+
8
9
# Create TFLite converter
9
- converter = tf .lite .TFLiteConverter .from_saved_model (' chattts_tf' )
10
-
10
+ converter = tf .lite .TFLiteConverter .from_saved_model (" chattts_tf" )
11
+
11
12
# Set optimization flags
12
13
converter .optimizations = [tf .lite .Optimize .DEFAULT ]
13
14
converter .target_spec .supported_types = [tf .float32 ]
14
-
15
+
15
16
# Convert the model
16
17
tflite_model = converter .convert ()
17
-
18
+
18
19
# Save the TFLite model
19
- with open (' chattts_model.tflite' , 'wb' ) as f :
20
+ with open (" chattts_model.tflite" , "wb" ) as f :
20
21
f .write (tflite_model )
21
-
22
+
22
23
print ("Model converted successfully to TFLite format" )
23
24
24
- if __name__ == '__main__' :
25
- convert_to_tflite ()
25
+
26
+ if __name__ == "__main__" :
27
+ convert_to_tflite ()
You can’t perform that action at this time.
0 commit comments