Skip to content

Instantly share code, notes, and snippets.

View tomrunia's full-sized avatar

Tom Runia tomrunia

View GitHub Profile
@tomrunia
tomrunia / video_input_pipeline.py
Created January 9, 2018 15:28
TensorFlow video input pipeline using TFRecord files (for Kinetics dataset)
def decode(serialized_example, sess):
'''
Given a serialized example in which the frames are stored as
compressed JPG images 'frames/0001', 'frames/0002' etc., this
function samples SEQ_NUM_FRAMES from the frame list, decodes them from
JPG into a tensor and packs them to obtain a tensor of shape (N,H,W,3).
Returns the the tuple (frames, class_label (tf.int64)
:param serialized_example: serialized example from tf.data.TFRecordDataset
:return: tuple: (frames (tf.uint8), class_label (tf.int64)
@tomrunia
tomrunia / tensorflow_log_loader.py
Created March 2, 2016 09:11
Reading out binary TensorFlow log file and plotting process using MatplotLib
import numpy as np
from tensorflow.python.summary.event_accumulator import EventAccumulator
import matplotlib as mpl
import matplotlib.pyplot as plt
def plot_tensorflow_log(path):
# Loading too much data is slow...
tf_size_guidance = {
@tomrunia
tomrunia / tf_queue.py
Created November 2, 2016 14:48
TensorFlow queue example
# Initialize placeholders for feeding in to the queue
pl_queue_screens = tf.placeholder(tf.float32, shape=[config.seq_length, config.image_size, config.image_size, config.input_channels], name="queue_inputs")
pl_queue_targets = tf.placeholder(tf.uint8, shape=[config.seq_length], name="queue_targets_cnt")
# ...
capacity = config.min_after_dequeue + 10 * (config.num_gpus*config.batch_size)
q = tf.RandomShuffleQueue(
# MIT License
#
# Copyright (c) 2017 Tom Runia
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to conditions.
#!/usr/bin/python
import os
# YouTube video searching API
from apiclient.discovery import build
from apiclient.errors import HttpError
from oauth2client.tools import argparser
# Downloading YouTube videos
import pafy
# Initialize the camera
camera = bpy.data.cameras.new('Camera')
camera_obj = bpy.data.objects.new('Camera', camera)
scene.objects.link(camera_obj)
scene.objects.active = camera_obj
scene.camera = camera_obj
camera_obj.select = True
camera_obj.location = (0, 0, 0)
Block Elements Kernel Size Filter depth Output depth Stride Misc. Info
Convolution [5, 5] 3 64 [1, 1]
conv1 ReLU - - - -
Max-pool [3, 3] - - [2, 2]
Convolution [5, 5] 64 64 [1, 1]
conv2 ReLU - - - -
Max-pool [3, 3] - - [2, 2]
# Initialize placeholders for feeding in to the queue
self.queue_inputs = tf.placeholder(tf.float32, shape=[None, self.config.seq_length, self.config.image_size, self.config.image_size], name="queue_inputs")
self.queue_targets = tf.placeholder(tf.uint8, shape=[None, self.config.seq_length], name="queue_targets")
min_after_dequeue = 10000
capacity = min_after_dequeue + 3 * self.config.batch_size
q = tf.FIFOQueue(
def load_and_enqueue(input_dir, sess, coord, enqueue_op, queue_inputs, queue_targets, num_examples, examples_per_file=100, rewrite_targets=True):
# Check if we have a sufficient number of HDF5 files to load all the samples
filenames_queue = glob.glob(os.path.join(input_dir, "train/*.h5"))
filenames_queue.sort()
assert len(filenames_queue) > 0
examples_available = len(filenames_queue)*examples_per_file
num_examples = min(examples_available, num_examples)
require 'image'
require 'lfs'
require 'cunn'
require 'nngraph'
function segment(model, flow_mag_ang_file, minmax_file, output_file)
local file = io.open(minmax_file)
local minmaxes = {}
local ind = 1;