Skip to content

Instantly share code, notes, and snippets.

dolaameng / README.MD
Created Jun 5, 2018
classification for peta

Use PETA Dataset for Gender Detection


  1. Download dataset from here
  2. Uncompress the dataset to PETA, it should contain 10 subfolders like this
drwxrwxr-x 3 dola dola 4096 Oct 20  2014 3DPeS
drwxrwxr-x 3 dola dola 4096 Oct 20  2014 CAVIAR4REID
drwxrwxr-x 3 dola dola 4096 Oct 20  2014 CUHK
drwxrwxr-x 3 dola dola 4096 Oct 20  2014 GRID
dolaameng /
Created Jan 24, 2018 — forked from kaito834/
Python 3.x snippet code for Basic Authentication HTTP request by urllib.request
#!/usr/bin/env python
# I tested by Python 3.4.3 on Windows 8.1
# Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32
import urllib.request
import getpass
# If you access to url below via Proxy,
# set environment variable 'http_proxy' before execute this.
dolaameng /
Last active Nov 15, 2017
tensorflow saved_model, `tags` is the `key` to the metagraph
import tensorflow as tf
import numpy as np
# graph
x = tf.placeholder(tf.float32, [], name='x')
y = tf.multiply(x, 2, name='y')
z = tf.add(x, 1, name='z')
# signature

TensorFlow Serving in 10 minutes!

TensorFlow SERVING is Googles' recommended way to deploy TensorFlow models. Without proper computer engineering background, it can be quite intimidating, even for people who feel comfortable with TensorFlow itself. Few things that I've found particularly hard were:

  • Tutorial examples have C++ code (which I don't know)
  • Tutorials have Kubernetes, gRPG, Bezel (some of which I saw for the first time)
  • It needs to be compiled. That process takes forever!

After all, it worked just fine. Here I present an easiest possible way to deploy your models with TensorFlow Serving. You will have your self-built model running inside TF-Serving by the end of this tutorial. It will be scalable, and you will be able to query it via REST.

dolaameng /
Created Oct 19, 2017 — forked from peterroelants/
Example using TensorFlow Estimator, Experiment & Dataset on MNIST data.
"""Script to illustrate usage of tf.estimator.Estimator in TF v1.3"""
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data as mnist_data
from tensorflow.contrib import slim
from tensorflow.contrib.learn import ModeKeys
from tensorflow.contrib.learn import learn_runner
# Show debugging output
dolaameng / Eigen Cheat sheet
Created Jul 24, 2017 — forked from gocarlos/Eigen Cheat sheet
Cheat sheet for the linear algebra library Eigen:
View Eigen Cheat sheet
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
dolaameng /
Last active Dec 31, 2021
Variable Length Sequence for RNN in pytorch Example
import torch
import torch.nn as nn
from torch.autograd import Variable
batch_size = 3
max_length = 3
hidden_size = 2
n_layers =1
# container
View gist:03dde943e7a4abc8edec4aa8bd7d0550
def color_hist(img, nbins=32, bins_range=(0, 256)):
# Compute the histogram of the color channels separately
channel1_hist = np.histogram(img[:,:,0], bins=nbins, range=bins_range)
channel2_hist = np.histogram(img[:,:,1], bins=nbins, range=bins_range)
channel3_hist = np.histogram(img[:,:,2], bins=nbins, range=bins_range)
# Concatenate the histograms into a single feature vector
hist_features = np.concatenate((channel1_hist[0], channel2_hist[0], channel3_hist[0]))
# Return the individual histograms, bin_centers and feature vector
return hist_features
dolaameng /
Last active Jan 29, 2017
save/restore models in tf 0.12
######################################## train and save model in
# input, output, hyperparameter as placeholders, e.g.
x = tf.placeholder(tf.float32, (None, 32, 32, 3), name="x")
y = tf.placeholder(tf.int32, (None), name="y")
keep_prob = tf.placeholder(tf.float32, name="keep_prob")
# build model
yhat, loss = build_whatevermodel(x)
train_op = whateveroptimizer.minimize(loss)
dolaameng /
Created Sep 6, 2016
Keras neural_doodle result
'''Neural doodle with Keras
Script usage:
python nb_colors path_to_style_image.png path_to_style_mask.png \
[optional_path_to_content_image] \
path_to_your_doodle.png prefix_for_results