Skip to content

Instantly share code, notes, and snippets.

View sjain07's full-sized avatar

Sarthak Jain sjain07

View GitHub Profile
icons
import picamera, json, requests, os, random
from time import sleep
from PIL import Image, ImageDraw
#capture an image
camera = picamera.PiCamera()
camera.capture('image1.jpg')
print('caputred image')
#make a prediction on the image
import picamera, os
from PIL import Image, ImageDraw
camera = picamera.PiCamera()
camera.capture('image1.jpg')
os.system("xdg-open image1.jpg")
import requests, os, sys
model_id = os.environ.get('NANONETS_MODEL_ID')
api_key = os.environ.get('NANONETS_API_KEY')
image_path = sys.argv[1]
url = 'https://app.nanonets.com/api/v2/ObjectDetection/Model/' + model_id + '/LabelFile/'
data = {'file': open(image_path, 'rb'), 'modelId': ('', model_id)}
image = readImage()
NoOfCells = 7
NoOfClasses = 4
threshold = 0.7
step = height(image)/NoOfCells
prediction_class_array = new_array(size(NoOfCells,NoOfCells,NoOfClasses))
predictions_bounding_box_array = new_array(size(NoOfCells,NoOfCells,NoOfCells,NoOfCells))
final_predictions = []
for (i<0; i<NoOfCells; i=i+1):
for (j<0; j<NoOfCells;j=j+1):
#this is an Image of size 140x140. We will assume it to be black and white (ie only one channel, it would have been 140x140x3 for rgb)
image = readImage()
#We will break the Image into 7 coloumns and 7 rows and process each of the 49 different parts independently
NoOfCells = 7
#we will try and predict if an image is a dog, cat, cow or wolf. Therfore the number of classes is 4
NoOfClasses = 4
threshold = 0.7
@sjain07
sjain07 / Dockerfile
Last active February 27, 2018 20:54
RaspberryPiTensorFlow
FROM tensorflow/tensorflow:1.5.0-gpu
RUN apt-get update && apt-get install -y --no-install-recommends \
python-pip \
protobuf-compiler \
python-pil \
python-lxml \
python-numpy \
python-scipy \
python-dev \
python-pip \
@sjain07
sjain07 / FacebookDetectronInstall.sh
Created January 25, 2018 14:04
Install and test Facebook Detectron
#!/bin/bash
set -e
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
libgoogle-glog-dev \
libprotobuf-dev \
protobuf-compiler \
@sjain07
sjain07 / nginx.conf
Last active October 13, 2017 17:54
Url shortener using nginx and lua
events {}
http {
upstream pgdb {
postgres_server urlshortnertestdb.cccccccccccc.us-west-2.rds.amazonaws.com dbname=redirect user=root password=password;
}
server {
listen 80;
server_name localhost;
with tf.Session(graph=graph) as session:
init.run()
average_loss = 0
for step in range(10001):
batch_inputs, batch_labels = generate_batch(batch_size, num_skips, skip_window)
feed_dict = {train_inputs: batch_inputs, train_labels: batch_labels}
_, loss_val, normalized_embeddings_np = session.run([optimizer, loss, normalized_embeddings], feed_dict=feed_dict)
average_loss += loss_val
final_embeddings = normalized_embeddings.eval()