# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: 'Python 3.8.3 64-bit (''ProgramData'': virtualenv)'
#     metadata:
#       interpreter:
#         hash: b3ba2566441a7c06988d0923437866b63cedc61552a5af99d1f4fb67d367b25f
#     name: 'Python 3.8.3 64-bit (''ProgramData'': virtualenv)'
# ---

import tensorflow as tf
saved_model = (r"\\wsl$\Ubuntu\home\guilo\nsfw_model\tf1\training\mobilenetv2_transfer\nude_mobilenetv2_train")
model = (r"\\wsl$\Ubuntu\home\guilo\nsfw_model\tf1\training\mobilenetv2_transfer\nude_mobilenet2.224x224.h5")

# + tags=[]
# Convert the model.
converter = tf.compat.v1.lite.TFLiteConverter.from_keras_model_file(model)
tflite_model = converter.convert()

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

converter = tf.lite.TFLiteConverter.from_saved_model(saved_model)
tflite_model = converter.convert()
open("converted_model.tflite", "wb").write(tflite_model)

converter = tf.lite.TFLiteConverter.from_saved_model(saved_model)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
tflite_quant_model = converter.convert()
open("converted_model_quant.tflite", "wb").write(tflite_quant_model)

StarcoderdataJupyterScriptsDedupFiltered