Skip to content

Instantly share code, notes, and snippets.

%cd /mydrive/customTF2/data/
import tensorflow as tf
saved_model_dir = '/mydrive/customTF2/data/tflite/saved_model'
techzizou /
Last active November 4, 2021 19:00
Script to create TFLite model with metadata
from tflite_support.metadata_writers import object_detector
from tflite_support.metadata_writers import writer_utils
from tflite_support import metadata
import flatbuffers
import os
from tensorflow_lite_support.metadata import metadata_schema_py_generated as _metadata_fb
from tensorflow_lite_support.metadata.python import metadata as _metadata
from tensorflow_lite_support.metadata.python.metadata_writers import metadata_info
from tensorflow_lite_support.metadata.python.metadata_writers import metadata_writer
from tensorflow_lite_support.metadata.python.metadata_writers import writer_utils
#Loading the saved_model
import tensorflow as tf
import time
import numpy as np
import warnings
from PIL import Image
from google.colab.patches import cv2_imshow
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as viz_utils
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
import os
import io
import pandas as pd
import tensorflow as tf
import argparse
import numpy as np
import os
import cv2
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from google.colab.patches import cv2_imshow
classes = 2
train = data/train.txt
valid = data/test.txt
names = data/obj.names
backup = /mydrive/yolov4/training
import glob, os
# Current directory
current_dir = os.path.dirname(os.path.abspath(__file__))
current_dir = 'data/obj'
# Percentage of images to be used for the test set