Skip to content

Instantly share code, notes, and snippets.

View lhoangan's full-sized avatar

Hoàng-Ân Lê lhoangan

View GitHub Profile
@lhoangan
lhoangan / tf-interleaving.py
Last active June 11, 2019 16:25
Interleaving 2 or more arrays in tensorflow
import tensorflow as tf
import numpy as np
a = np.array([[1, 4, 7, 10], [11, 44, 77, 110]]) # shape (2, 4)
b = np.array([[2, 5, 8, 11], [22, 55, 88, 111]]) # shape (2, 4)
c = np.array([[3, 6, 9, 12], [33, 66, 99, 122]]) # shape (2, 4)
A = tf.convert_to_tensor(a)
B = tf.convert_to_tensor(b)
C = tf.convert_to_tensor(c)
@lhoangan
lhoangan / flow_color.py
Last active May 11, 2018 20:15
Optical flow utilities
import numpy as np
from math import pi
def convert(flow):
UNKNOWN_FLOW_THRESH = 1e9
h, w, nBands = flow.shape
assert nBands == 2, 'flow_to_color: image must have two bands'