Skip to content

Instantly share code, notes, and snippets.

View beniroquai's full-sized avatar

Benedict Diederich beniroquai

  • IPHT Leibniz Institute of Photonic Technology's
View GitHub Profile
@marvin
marvin / client.py
Created December 17, 2012 13:50
simple python client/server socket binary stream
import socket
HOST = 'localhost'
PORT = 9876
ADDR = (HOST,PORT)
BUFSIZE = 4096
videofile = "videos/royalty-free_footage_wien_18_640x360.mp4"
bytes = open(videofile).read()
@n3wtron
n3wtron / simple_mjpeg_streamer_http_server
Last active July 8, 2024 17:49
Simple Python Motion Jpeg (mjpeg server) from webcam. Using: OpenCV,BaseHTTPServer
#!/usr/bin/python
'''
Author: Igor Maculan - n3wtron@gmail.com
A Simple mjpg stream http server
'''
import cv2
import Image
import threading
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from SocketServer import ThreadingMixIn
@yetithefoot
yetithefoot / stuns
Last active July 13, 2024 17:34 — forked from zziuni/stuns
STUN+TURN servers list
{url:'stun:stun01.sipphone.com'},
{url:'stun:stun.ekiga.net'},
{url:'stun:stun.fwdnet.net'},
{url:'stun:stun.ideasip.com'},
{url:'stun:stun.iptel.org'},
{url:'stun:stun.rixtelecom.se'},
{url:'stun:stun.schlund.de'},
{url:'stun:stun.l.google.com:19302'},
{url:'stun:stun1.l.google.com:19302'},
{url:'stun:stun2.l.google.com:19302'},
@oneyoung
oneyoung / AndroidTakePicture.java
Last active August 2, 2020 15:59
Take Picture using Android Camera API: android.hardware.Camera
private void doTakePicture(final int cameraId) throws Exception {
/*
Camera class is not thread-safe, and is meant for use from one event thread.
Most long-running operations (preview, focus, photo capture, etc) happen asynchronously
and invoke callbacks as necessary.
Callbacks will be invoked on the event thread open(int) was called from.
This class's methods must never be called from multiple threads at once.
*/
/* Important: mCamera object must be alloc in another Thread, othwerwise, callback will NOT be invoked.
@karpathy
karpathy / min-char-rnn.py
Last active July 18, 2024 15:59
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@poolio
poolio / depth_to_space_viz.py
Last active May 6, 2020 07:01
Subpixel convolution is tf.depth_to_space
def _phase_shift(I, r):
bsize, a, b, c = I.get_shape().as_list()
X = tf.reshape(I, (bsize, a, b, r, r))
X = tf.transpose(X, (0, 1, 2, 4, 3)) # bsize, a, b, 1, 1
X = tf.split(1, a, X) # a, [bsize, b, r, r]
X = tf.concat(2, [tf.squeeze(x, [1]) for x in X]) # bsize, b, a*r, r
X = tf.split(1, b, X) # b, [bsize, a*r, r]
X = tf.concat(2, [tf.squeeze(x, [1]) for x in X]) # bsize, a*r, b*r
return tf.reshape(X, (bsize, a*r, b*r, 1))
@omimo
omimo / create_hellotensor.py
Last active September 26, 2023 08:37
A simple example for saving a tensorflow model and preparing it for using on Android
# Create a simple TF Graph
# By Omid Alemi - Jan 2017
# Works with TF <r1.0
import tensorflow as tf
I = tf.placeholder(tf.float32, shape=[None,3], name='I') # input
W = tf.Variable(tf.zeros_initializer(shape=[3,2]), dtype=tf.float32, name='W') # weights
b = tf.Variable(tf.zeros_initializer(shape=[2]), dtype=tf.float32, name='b') # biases
O = tf.nn.relu(tf.matmul(I, W) + b, name='O') # activation / output
@revsic
revsic / ConvLSTMCell.py
Last active April 5, 2020 17:06
Tensorflow implementation of Convolutional LSTM
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
from __future__ import print_function
import PIL.Image
import PIL.ExifTags
import sys
import os
def formatted_exif_data(image):
"""Retrieve an image's EXIF data and return as a dictionary with string keys"""
# with thanks to https://stackoverflow.com/questions/4764932/in-python-how-do-i-read-the-exif-data-for-an-image
exif_data = {}
@gnperdue
gnperdue / hdf5_batch_test.py
Last active November 30, 2023 15:42
TensorFlow Dataset `from_generator` reading HDF5
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division
import os
import h5py
import numpy as np
import tensorflow as tf
# Get path to data