Skip to content

Instantly share code, notes, and snippets.

View mkocabas's full-sized avatar

Muhammed Kocabas mkocabas

View GitHub Profile
####################### retinanet.py
def default_null_model(
pyramid_feature_size=256,
name='null_submodel'
):
options = {
'kernel_size' : 3,
'strides' : 1,
'padding' : 'same',
}
@mkocabas
mkocabas / the2_knn.m
Created December 14, 2017 20:00
K Nearest Neighbor Implementation in Matlab
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% In this tutorial, we are going to implement knn algorithm. %
% Our aim is to see the most efficient implementation of knn. %
% You have to implement knn in two differnt ways: %
% 1) with two loops %
% 2) without any loop %
% %
% you have to report the computation times of both pathways. %
% Note: the distance metric is �Euclidean�. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@mkocabas
mkocabas / training.py
Last active December 15, 2017 13:12
Pose grammar training
import numpy as np
from pycocotools.coco import COCO
import os
import math
import keras
from keras.models import Model
from keras.layers import Dense, Input, Flatten, Reshape
from keras.utils import plot_model
from random import shuffle
name: "1546"
layer {
name: "data"
type: "ImageSegData"
top: "data"
top: "label"
#top: "data_dim"
include {
phase: TRAIN
from keras.optimizers import Optimizer
from keras import backend as K
from keras.legacy import interfaces
class MultiSGD(Optimizer):
"""
Modified SGD with added support for learning multiplier for kernels and biases
as suggested in: https://github.com/fchollet/keras/issues/5920
def focal_loss(gamma=2, alpha=0.75):
def focal_loss_fixed(y_true, y_pred): # compatible with tf backend
pt_1 = tf.where(tf.equal(y_true, 1), y_pred, tf.ones_like(y_pred))
pt_0 = tf.where(tf.equal(y_true, 0), y_pred, tf.zeros_like(y_pred))
return -K.sum(alpha * K.pow(1. - pt_1, gamma) * K.log(pt_1))-K.sum((1-alpha) * K.pow( pt_0, gamma) * K.log(1. - pt_0))
return focal_loss_fixed
tb = TensorBoard(
log_dir='./logs/{}'.format(args.exp_dir),
histogram_freq=0,
batch_size=args.batch_size,
write_graph=True,
write_batch_performance=True,
write_grads=False,
write_images=False,
embeddings_freq=0,
embeddings_layer_names=None,
# coding: utf-8
# In[ ]:
"""
Copyright (c) 2017, by the Authors: Amir H. Abdi
This software is freely available under the MIT Public License.
Please see the License file in the root for details.
@mkocabas
mkocabas / coco.sh
Created April 9, 2018 09:41
Download COCO dataset. Run under 'datasets' directory.
mkdir coco
cd coco
mkdir images
cd images
wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip
wget http://images.cocodataset.org/zips/test2017.zip
wget http://images.cocodataset.org/zips/unlabeled2017.zip
import keras
from keras.layers import Conv2D, UpSampling2D, BatchNormalization, Input, Add, MaxPool2D, Activation, Concatenate
from keras.models import Model
from utils.config import num_stages, num_joints
nFeatures = 256
nStack = 8
nModules = 1
nOutChannels = num_joints