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
//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
# 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"
# 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')
!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
# Install TensorFlow 1.0
!pip install tensorflow==1.0
# Install dependencies of the DarkFlow
!apt-get update
!pip3 install numpy
!apt-get install python-opencv -y
!pip install cython
# Clean up the directory
# Install TensorFlow 1.13.1
!pip install tensorflow==1.13.1
# Get the repo
!git clone "https://github.com/jinyu121/DW2TF.git"
%cd DW2TF
!python3 main.py \
--cfg "PATH_to_config/yolo-v2-tiny-coco.cfg" \
--weights "PATH_to_weights/yolo-v2-tiny-coco.weights" \
--output "content/" \
# Note: The author has kept the weights and cfg files strictly in their respective directories.
# If you add yours, do place them in the same folders
!pip install onnx==1.6.0 onnx-tf==1.5.0
!pip install tensorflow-gpu==1.15.0
%cd repo
!wget "https://pjreddie.com/media/files/yolov3-tiny.weights" -O "/weights/"
# The cfg file is already present in the repo.
# Install TensorFlow
!pip install tensorflow==1.11.0
# Get repository
!git clone https://github.com/mystic123/tensorflow-yolo-v3.git
%cd tensorflow-yolo-v3
!git checkout ed60b90
# Get coco.names
!wget https://raw.githubusercontent.com/pjreddie/darknet/master/data/coco.names
@pra-dan
pra-dan / pandas_cheatsheet.md
Created August 19, 2020 08:34
pandas cheatsheet :)
  1. Remove all entries with empty strings OR empty cells
for col in rawData.columns: # Iterate over all cols
  #print(f'col: {col}')  
  
  # Replace empty strings (if any), with NaN
  df[col].replace('', np.nan, inplace=True)
  
  # Remove all rows with any entry = NaN
 df.dropna(subset=[col], inplace=True)
import bpy
import os
from math import *
from mathutils import *
#set your own target here
target = bpy.data.objects['Cube']
cam = bpy.data.objects['Camera']
t_loc_x = target.location.x
t_loc_y = target.location.y