Skip to content

Instantly share code, notes, and snippets.

View pra-dan's full-sized avatar
💭
Seeking Edge AI opportunities

Prashant Dandriyal pra-dan

💭
Seeking Edge AI opportunities
View GitHub Profile
!pip install tensorflow-gpu==1.15.0
# Convert
!toco --graph_def_file /content/yolo-v2-tiny-coco.pb \
--output_file yolo-v2-tiny-coco.tflite \
--output_format TFLITE \
--inference_type FLOAT \
--inference_input_type FLOAT \
--input_arrays input \
--output_arrays output
# This script will help print the inputs and output layer names of Tensorflow graph files (.pb)
import tensorflow as tf
gf = tf.GraphDef()
m_file = open('/content/frozen_darknet_yolov3_model.pb','rb')
gf.ParseFromString(m_file.read())
with open('somefile.txt', 'a') as the_file:
for n in gf.node:
the_file.write(n.name+'\n')
# Obtain frozen graph of mobilenet v1
!wget "http://download.tensorflow.org/models/mobilenet_v1_2018_08_02/mobilenet_v1_1.0_224.tgz"
!tar -xf mobilenet_v1_1.0_224.tgz
# Get TensorFlow source code repo
!git clone "https://github.com/tensorflow/tensorflow.git"
# Optimize graph using TensorFlow tool
!python "/content/tensorflow/tensorflow/python/tools/optimize_for_inference.py" --input=mobilenet_v1_1.0_224_frozen.pb --output=mobilenet_v1_1.0_224_final.pb --input_names=input --output_names="MobilenetV1/Predictions/Softmax"
//Tencent is pleased to support the open source community by making FeatherCNN available.
//Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
//Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
//in compliance with the License. You may obtain a copy of the License at
//
//https://opensource.org/licenses/BSD-3-Clause
//
//Unless required by applicable law or agreed to in writing, software distributed