Skip to content

Instantly share code, notes, and snippets.

View Coderx7's full-sized avatar
💭
In God we Trust!

Seyyed Hossein Hasanpour Coderx7

💭
In God we Trust!
View GitHub Profile
@Coderx7
Coderx7 / wrn_151_v7.prototxt
Created April 24, 2017 08:03
wideresidual network in caffe wrn_151_v7
name: "wrn_151_v7"
layer {
name: "Data1"
type: "Data"
top: "Data1"
top: "Data2"
include {
phase: TRAIN
}
transform_param {
@Coderx7
Coderx7 / caffe_feature_extractor.py
Last active July 22, 2017 17:47 — forked from marekrei/caffe_feature_extractor.py
Caffe feature extractor
#in the name of Allah, the most compassionate the most merciful
#run this scrip under python2. python3 would work, but not prefectly. e.g. running this script and setting oversample to true in
#net.predict([input_image], oversample=True) will cause a crash. but it works just fine under python2.
import numpy as np
import os, sys, getopt
# Main path to your caffe installation
caffe_root = '/path/to/your/caffe/'
# Model prototxt file
@Coderx7
Coderx7 / plot_train_test_caffe_rc5.py
Created April 9, 2017 11:20
script for plotting training and testing accuracy/loss together for the latest version of caffe (rc5)
# In the name of GOD the most compassionate the most merciful
# Last Updated : 4/9/2017 , updated the regex for the latest caffe (rc5) logs
# Originally developed by Yasse Souri
# Just added the search for current directory so that users dont have to use command prompts anymore!
# and also shows the top 4 accuracies achieved so far, and displaying the highest in the plot title
# Coded By: Seyyed Hossein Hasan Pour ([email protected])
# -------How to Use ---------------
# 1.Just place your caffe's traning/test log file (with .log extension) next to this script
# and then run the script.If you have multiple logs placed next to the script, it will plot all of them
# you may also copy this script to your working directory, where you generate/keep your train/test logs
@Coderx7
Coderx7 / load_jpeg_with_tensorflow.py
Created April 8, 2017 06:20 — forked from eerwitt/load_jpeg_with_tensorflow.py
Example loading multiple JPEG files with TensorFlow and make them available as Tensors with the shape [[R, G, B], ... ].
# Typical setup to include TensorFlow.
import tensorflow as tf
# Make a queue of file names including all the JPEG images files in the relative
# image directory.
filename_queue = tf.train.string_input_producer(
tf.train.match_filenames_once("./images/*.jpg"))
# Read an entire image file which is required since they're JPEGs, if the images
# are too large they could be split in advance to smaller files or use the Fixed
@Coderx7
Coderx7 / plot_train_test.py
Last active March 12, 2017 13:51
a script to plot train and test curves altogether.
# In the name of GOD the most compassionate the most merciful
# Originally developed by Yasse Souri
# Just added the search for current directory so that users dont have to use command prompts anymore!
# and also shows the top 4 accuracies achieved so far, and displaying the highest in the plot title
# Added train/test plot!
# Coded By: Seyyed Hossein Hasan Pour ([email protected])
# -------How to Use ---------------
# 0.First of all make sure your test layers name is 'accuracy' and the layer which reports your training accuracy is
# 'accuracy_training'. then you are good to go. if you are using different names for your test/train layers, make sure to edit
# the regex yourself. I might remove this limitation later, but at the moment this is a hacky edition to get my job done!
@Coderx7
Coderx7 / plot_train_test.py
Created March 12, 2017 13:50
a script to plot train and test curves altogether.
# In the name of GOD the most compassionate the most merciful
# Originally developed by Yasse Souri
# Just added the search for current directory so that users dont have to use command prompts anymore!
# and also shows the top 4 accuracies achieved so far, and displaying the highest in the plot title
# Coded By: Seyyed Hossein Hasan Pour ([email protected])
# -------How to Use ---------------
# 0.First of all make sure your test layers name is 'accuracy' and the layer which reports your training accuracy is
# 'accuracy_training'. then you are good to go. if you are using different names for your test/train layers, make sure to edit
# the regex yourself. I might remove this limitation later, but at the moment this is a hacky edition to get my job done!
# so the code isnot polished! but is straight forward!
@Coderx7
Coderx7 / CIFAR10_Pylearn2_To_LMDB_Convertor.py
Created February 14, 2017 11:01
This is the script which I wrote to convert the cifar10/100 (gcn,whitened) datasets from pylearn2 to lmdb.
#in the name of GOD
#pylearn2 cifar10 convertor to lmdb
#by:Seyyed Hossein Hasanpour
#[email protected]
#2/14/2017
import numpy as np
import cPickle
import lmdb
import caffe
from caffe.proto import caffe_pb2
@Coderx7
Coderx7 / cifar10-normalize.py
Created January 12, 2017 18:30
CIfar10-lmdb-zeropad-normalize script for caffe
#in the name of God, the most compassionate the most merciful
#Seyyed Hossein Hasanpour
#[email protected]
#script for zeropadding and normalizing CIFAR10 dataset (can also be used for CIFAR100)
import math
import caffe
import lmdb
import numpy as np
from caffe.proto import caffe_pb2
import cv2
@Coderx7
Coderx7 / mean-std.py
Last active January 12, 2017 18:05
mean and std calculation with non-vectorized and semi-vectorized implementation, good candidates for times numpy.mean and numpy.std does not work! because of memory issues
#In the name of God, the most compassionate the most merciful
import math
import numpy as np
#English: a simple handy snippet which I specifically wrote for calculating mean for a batch of images,
#in semi-vectorized and unvectorized fashion, along with the fully numpy example to test the output!
#Farsi:
#mohasebe mean batchi az tasavir be sorate vectorized, unvectorized and semi vectorized
#age version vectorized error kambod hafeze dad, behtare az semi vectorized estefade beshe
#chon unvectorized ya hamoon loop mamoli sooratesh kheyli kame.
#[email protected]
@Coderx7
Coderx7 / calculate_std.py
Last active January 12, 2017 18:37
a non-vectorized and semi-vectorized implementation for calculating std for a batch of images. the semi-vectorized is the one, one should use, since its as fast as the numpy.std
#In the name of God, the most compassionate the most merciful
#a non-vectorized and semi-vectorized implementation for calculating std for a batch of images.
#the semi-vectorized is the one, one should use, since its as fast as the numpy.std
#Seyyed Hossein Hasan pour
#[email protected]
#1/12/2017
import math
#unvectorized version --really slow!
def calc_std_classic(a):
#sum all elements in each channel and divide by the number of elements