Skip to content

Instantly share code, notes, and snippets.

View savan77's full-sized avatar

Savan Visalpara savan77

View GitHub Profile
@savan77
savan77 / ocr.yaml
Created October 20, 2020 21:53
OCR Template
- name: ocr-detector
inputs:
artifacts:
- name: tsrc
path: /mnt/src/train
git:
repo: 'https://github.com/onepanelio/LicensePlateOcr.git'
- git:
repo: https://github.com/tensorflow/models.git
name: src
@savan77
savan77 / detection.yaml
Created October 20, 2020 21:52
License Plate Detection Template
- name: license-detector
inputs:
artifacts:
- name: src
path: /mnt/src
git:
repo: "https://github.com/onepanelio/LicensePlateOcr.git"
- name: data
path: /mnt/data/datasets/
s3:
@savan77
savan77 / attention-ocr-training.yaml
Created October 20, 2020 21:51
Attention-OCR Training Template
arguments:
parameters:
- name: source
value: https://github.com/tensorflow/models.git
displayName: Model source code
type: hidden
visibility: private
- name: trainingsource
value: https://github.com/onepanelio/LicensePlateOcr.git
@savan77
savan77 / ocr_inference.py
Created October 20, 2020 21:50
OCR Inference
def run(checkpoint, batch_size, dataset_name, image_path_pattern, annotations):
images_placeholder, endpoints = create_model(batch_size,
dataset_name)
session_creator = monitored_session.ChiefSessionCreator(
checkpoint_filename_with_path=checkpoint)
count = 0
width, height = get_dataset_image_size(dataset_name)
with monitored_session.MonitoredSession(
session_creator=session_creator) as sess:
for path,boxes in annotations.items():
@savan77
savan77 / train.py
Created October 20, 2020 21:50
Training command
python train.py \
--dataset_name=custom \
--batch_size=1 \
--train_log_dir=/mnt/output/ \
--checkpoint=model.ckpt-399731 \
--max_number_of_steps=110000
@savan77
savan77 / crop.py
Created October 20, 2020 21:49
Crop license plates
def get_crops(args):
tree = ET.parse(args.xml_file)
root = tree.getroot()
count = 0
if not os.path.exists(args.output_dir):
os.makedirs(args.output_dir)
for image in root.iter('image'):
@savan77
savan77 / inference.py
Last active October 20, 2020 21:48
TF Inference Script
scores = detection_graph.get_tensor_by_name('detection_scores:0')
classes = detection_graph.get_tensor_by_name('detection_classes:0')
num_detections = detection_graph.get_tensor_by_name('num_detections:0')
(boxes, scores, classes, num_detections) = sess.run([boxes, scores, classes, num_detections], feed_dict={image_tensor: image_np_expanded})
result = []
for i in range(len(classes[0])):
if scores[0][i] >= 0.5:
xmin, ymin, xmax, ymax = _normalize_box(boxes[0][i], width, height)
label = CLASSES[classes[0][i]]
@savan77
savan77 / rnn-lstm.py
Last active January 21, 2017 18:05 — forked from monikkinom/rnn-lstm.py
Tensorflow RNN-LSTM implementation to count number of set bits in a binary string
#Source code with the blog post at http://monik.in/a-noobs-guide-to-implementing-rnn-lstm-using-tensorflow/
import numpy as np
import random
from random import shuffle
import tensorflow as tf
# from tensorflow.models.rnn import rnn_cell
# from tensorflow.models.rnn import rnn
##Create Dataset##
@savan77
savan77 / var.py
Last active January 11, 2017 09:39
import tensorflow as tf
#create a variable
#Synatx - tf.Variable(<initial-value>, name="")
x = tf.Variable(3, name="x")
y = tf.Variable(4, name="y")
#add x,y
c = tf.add(x,y)