Skip to content

Instantly share code, notes, and snippets.

View sameerg07's full-sized avatar

Sameer Gadicherla sameerg07

View GitHub Profile
@sameerg07
sameerg07 / inception_train.py
Created July 11, 2018 06:25
Training the keras inception model for custom classes
import os
import sys
import glob
import argparse
import matplotlib.pyplot as plt
from keras import __version__
from keras.applications.inception_v3 import InceptionV3, preprocess_input
from keras.models import Model
from keras.layers import Dense, GlobalAveragePooling2D
from keras.preprocessing.image import ImageDataGenerator
@sameerg07
sameerg07 / inception_test.py
Created July 11, 2018 06:29
Testing custom model using inception in keras
import sys
import argparse
import numpy as np
from PIL import Image
import requests
from io import BytesIO
import matplotlib.pyplot as plt
from PIL import Image,ImageDraw,ImageFont
from keras.preprocessing import image
from keras.models import load_model
@sameerg07
sameerg07 / simple_model.py
Created July 11, 2018 06:32
Keras simple model
model = Sequential()
model.add(Dense(32, activation='relu', input_dim=100))
model.add(Dense(1, activation='sigmoid'))
model.compile(optimizer='rmsprop',
loss='binary_crossentropy',
metrics=['accuracy'])
# Generate dummy data
import numpy as np
data = np.random.random((1000, 100))
@sameerg07
sameerg07 / thread_tf.py
Created July 11, 2018 06:33
thread and queues in tf
# Create the graph, etc.
init_op = tf.global_variables_initializer()
# Create a session for running operations in the Graph.
sess = tf.Session()
# Initialize the variables (like the epoch counter).
sess.run(init_op)
# Start input enqueue threads.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
try:
@sameerg07
sameerg07 / tensorflow_json_parser.py
Created July 11, 2018 12:13
converts the json file downloaded using image classifer tool of dataturks to dataset folder
#This script has been solely created under dataturks. Copyrights are reserved
#EXAMPLE USAGE
#python3 tensorflow_json_parser.py --json_file "flower.json" --dataset_path "Dataset5/"
import json
import glob
import urllib.request
@sameerg07
sameerg07 / keras_json_parser.py
Created July 11, 2018 12:24
parses the json file downloaded using the image classifier tool on dataturks to actual dataset
#This script has been solely created under dataturks. Copyrights are reserved
#EXAMPLE USAGE
#python3 keras_json_parser.py --json_file "flower.json" --dataset_path "Dataset5/" --train_percentage 80 --validation_percentage 20
import json
import glob
import urllib.request
import argparse
from keras.preprocessing.image import ImageDataGenerator,img_to_array, load_img
datagen = ImageDataGenerator(
rotation_range=40,
width_shift_range=0.2,
height_shift_range=0.2,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,
fill_mode='nearest')
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=input_shape))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
from keras.models import load_model
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D
from keras.layers import Activation, Dropout, Flatten, Dense
from keras import backend as K
import cv2
import numpy as np
@sameerg07
sameerg07 / fibonacci.py
Created June 4, 2021 03:41
fibonacci series generation for N numbers
def fibonacci(n):
if n == 1 or n == 2:
return n-1
else:
return fibonacci(n-1) + fibonacci(n-2)
n = int(input())
i = 1
while i <= n:
print(fibonacci(i))