Skip to content

Instantly share code, notes, and snippets.

@oak-tree
oak-tree / Attachable.java
Last active November 20, 2016 16:47
spring upload file
public interface Attachable {
public File getFile();
public String getTitle();
public String getDescription();
public String getRealFileName();
public Double getSize();//double?
public void saveFile(File destination);
}
for i in \"*\";do echo "$i"; mv "$i" "$(echo "$i" | tr -d \")";done;
1 #include <Python.h>
2 #include <iostream>
3 #include "theano_mod_helper.h"
4 #include "cuda_ndarray.cuh"
5 //////////////////////
6 //// Support Code
7 //////////////////////
8
9
10 namespace {
from keras import backend as K
if K.backend() == "tensorflow":
print("Using tensorflow - try to use jit")
import keras.backend.tensorflow_backend as bck
config = bck.tf.ConfigProto()
config.graph_options.optimizer_options.global_jit_level = bck.tf.OptimizerOptions.ON_1
bck.set_session(bck.tf.Session(config=config))
@oak-tree
oak-tree / gist:49fcbee1d2ecfb11c78b1b64bafc9a76
Created March 31, 2017 11:50
mnist_with_digit_limit_parameter
'''Train a Siamese MLP on pairs of digits from the MNIST dataset.
It follows Hadsell-et-al.'06 [1] by computing the Euclidean distance on the
output of the shared network and by optimizing the contrastive loss (see paper
for mode details).
[1] "Dimensionality Reduction by Learning an Invariant Mapping"
http://yann.lecun.com/exdb/publis/pdf/hadsell-chopra-lecun-06.pdf
Gets to 99.5% test accuracy after 20 epochs.
@oak-tree
oak-tree / remote_display.sh
Created June 19, 2017 15:32
remote display Xvfb
sudo apt-get install xvfb
nohup Xvfb :1 > /dev/null 2>&1 &
#testing with
python
import matplotlib
import matplotlib.pyplot as plt
@oak-tree
oak-tree / remote_display.sh
Created June 19, 2017 15:32
remote display Xvfb
sudo apt-get install xvfb
nohup Xvfb :1 > /dev/null 2>&1 &
#testing with
python
import matplotlib
import matplotlib.pyplot as plt
@oak-tree
oak-tree / install_opencv.sh
Last active August 22, 2017 17:40
install opencv 3.3 from sources
sudo apt-get install qt-sdk
then follow
#http://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
sudo apt-get install build-essential
#install python header and includes
#
sudo apt-get install python2.7-dev
sudo apt-get install python3.4-dev
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
@oak-tree
oak-tree / renew azure message lock.py
Created November 14, 2017 14:20
azure mssage lock
msg_locked_until = dateutil.parser.parse(msg.broker_properties['LockedUntilUtc'])
if (datetime.now(utc) + timedelta(0, lock_buff_seconds)) > msg_locked_until:
logger.info("Renewing message lock")
try:
msg.renew_lock()
logger.info("Done.")
except Exception as e:
logger.error("Failed renewing the message lock.")
logger.error(e.message)
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
def do_something(img):
return np.dot(img[...,:3], [0.299, 0.587, 0.114])
img = mpimg.imread('image.png')
result = do_something(img)
plt.imshow(result, cmap = plt.get_cmap('gray'))