Skip to content

Commit

Permalink
add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
m-romanenko committed Jul 7, 2020
1 parent c2eaccd commit 97f05db
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tf2_yolov4/tools/convert_tflite.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Script used to create a TfLite YOLOv4 model from previously trained weights.
"""

import click
import tensorflow as tf

Expand All @@ -15,6 +19,12 @@
"--weights_path", default=None, help="Path to .h5 file with model weights"
)
def convert_tflite(num_classes, weights_path):
"""Creates a .tflite file with a trained YOLOv4 model
Args:
num_classes (int): Number of classes
weights_path (str, optional): Path to .h5 pre-trained weights file
"""
model = YOLOv4(
input_shape=(HEIGHT, WIDTH, 3),
anchors=YOLOV4_ANCHORS,
Expand All @@ -38,8 +48,8 @@ def convert_tflite(num_classes, weights_path):
converter.allow_custom_ops = True
tflite_model = converter.convert()

with tf.io.gfile.GFile(TFLITE_MODEL_PATH, "wb") as f:
f.write(tflite_model)
with tf.io.gfile.GFile(TFLITE_MODEL_PATH, "wb") as file:
file.write(tflite_model)


if __name__ == "__main__":
Expand Down

0 comments on commit 97f05db

Please sign in to comment.