Skip to content

Instantly share code, notes, and snippets.

Thimira Amaratunga Thimira

  • Sri Lanka
Block or report user

Report or block Thimira

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Thimira
Thimira / bird_watch_train.py
Last active Dec 1, 2019
The main model training code from the Bird Watch project: https://github.com/Thimira/bird_watch . The project is currently live at https://www.birdwatch.photo/
View bird_watch_train.py
import numpy as np
from keras.preprocessing.image import ImageDataGenerator, img_to_array, load_img
from keras.models import Sequential, Model
from keras.layers import Dropout, Flatten, Dense, GlobalAveragePooling2D, Input
from keras.applications.inception_v3 import InceptionV3
from keras.utils.np_utils import to_categorical
from keras import optimizers
from keras.callbacks import EarlyStopping, ModelCheckpoint
from datetime import datetime, timedelta
import matplotlib.pyplot as plt
View snapchat_like_image_overlays.py
import numpy as np
import cv2
import dlib
from scipy.spatial import distance as dist
from scipy.spatial import ConvexHull
PREDICTOR_PATH = "../data/dlib_models/shape_predictor_68_face_landmarks.dat"
FULL_POINTS = list(range(0, 68))
FACE_POINTS = list(range(17, 68))
@Thimira
Thimira / ObjectTracker.py
Last active Jul 12, 2019
Track any object in a video with Dlib Correlation Trackers. Tutorial: https://www.codesofinterest.com/2018/02/track-any-object-in-video-with-dlib.html
View ObjectTracker.py
'''
Using Correlation Trackers in Dlib, you can track any object in a video stream without needing to train a custom object detector.
Check out the tutorial at: http://www.codesofinterest.com/2018/02/track-any-object-in-video-with-dlib.html
'''
import numpy as np
import cv2
import dlib
# this variable will hold the coordinates of the mouse click events.
mousePoints = []
@Thimira
Thimira / resnet50_predict.py
Created Sep 3, 2017
How to use the ResNet50 model from Keras Applications trained on ImageNet to make a prediction on an image.
View resnet50_predict.py
from keras.applications.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np
model = ResNet50(weights='imagenet')
img_path = 'Data/Jellyfish.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
@Thimira
Thimira / vgg16_predict.py
Created Sep 3, 2017
How to use the VGG16 model from Keras Applications trained on ImageNet to make a prediction on an image.
View vgg16_predict.py
from keras.applications.vgg16 import VGG16
from keras.preprocessing import image
from keras.applications.vgg16 import preprocess_input, decode_predictions
import numpy as np
model = VGG16(weights='imagenet')
img_path = 'Data/Jellyfish.jpg'
img = image.load_img(img_path, target_size=(224, 224))
img_data = image.img_to_array(img)
@Thimira
Thimira / vgg16_sequential.py
Created Sep 3, 2017
The VGG16 Deep Learning model created using the Sequential model of Keras v2
View vgg16_sequential.py
from keras.models import Sequential
from keras.layers.core import Flatten, Dense, Dropout
from keras.layers.convolutional import Conv2D, MaxPooling2D, ZeroPadding2D
from keras.optimizers import SGD
import numpy as np
def VGG_16(weights_path=None):
input_shape=(224,224,3)
model = Sequential()
@Thimira
Thimira / lenet_mnist_keras.py
Last active Feb 27, 2018
Deep Learning Beginner Tutorial. Using the LeNet model on the MNIST dataset for handwritten digit recognition. Works with Keras v2 and TensorFLow. This code is part of the book Build Deeper: Deep Learning Beginners' Guide (https://www.amazon.com/dp/B07564Y6CL)
View lenet_mnist_keras.py
# How to use
#
# Train the model and save the model weights
# python lenet_mnist_keras.py --train-model 1 --save-trained 1
#
# Train the model and save the model wights to a give directory
# python lenet_mnist_keras.py --train-model 1 --save-trained 1 --weights data/lenet_weights.hdf5
#
# Evaluate the model from pre-trained model wights
# python lenet_mnist_keras.py
@Thimira
Thimira / keras_bottleneck_multiclass.py
Last active Nov 4, 2019
Learn how to build a multi-class image classification system using bottleneck features from a pre-trained model in Keras to achieve transfer learning. Tutorial: https://www.codesofinterest.com/2017/08/bottleneck-features-multi-class-classification-keras.html
View keras_bottleneck_multiclass.py
'''
Using Bottleneck Features for Multi-Class Classification in Keras
We use this technique to build powerful (high accuracy without overfitting) Image Classification systems with small
amount of training data.
The full tutorial to get this code working can be found at the "Codes of Interest" Blog at the following link,
https://www.codesofinterest.com/2017/08/bottleneck-features-multi-class-classification-keras.html
Please go through the tutorial before attempting to run this code, as it explains how to setup your training data.
You can’t perform that action at this time.