Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Gygli gyglim

View GitHub Profile
@gyglim
gyglim / youtube_video_ids.txt
Last active July 29, 2020 15:55
Videos with few or no shot boundaries
View youtube_video_ids.txt
LtPYB0gpVrM
7TLngTUG9BU
3YeFK_mBl48
GReJlr_Fr8M
hQLqAou-_hU
zecY4uuXwSI
EaleKN9GQ54
RK1pR1Edax0
MVoLvrS_fFI
PxlEbfLy6GI
View stl10_dataset_info.json
{
"citation": "\n@inproceedings{coates2011stl10,\n title={{An Analysis of Single Layer Networks in Unsupervised Feature Learning}},\n author={Coates, Adam and Ng, Andrew and Lee, Honglak},\n booktitle={AISTATS},\n year={2011},\n note = {\\url{https://cs.stanford.edu/~acoates/papers/coatesleeng_aistats_2011.pdf}},\n}\n",
"description": "The STL-10 dataset is an image recognition dataset for developing unsupervised\nfeature learning, deep learning, self-taught learning algorithms. It is inspired\nby the CIFAR-10 dataset but with some modifications. In particular, each class\nhas fewer labeled training examples than in CIFAR-10, but a very large set of \nunlabeled examples is provided to learn image models prior to supervised\ntraining. The primary challenge is to make use of the unlabeled data (which\ncomes from a similar but different distribution from the labeled data) to build\na useful prior. All images were acquired from labeled examples on ImageNet.\n",
"downloadSize": "2640397119",
"location
@gyglim
gyglim / weizman_dataset.py
Last active December 7, 2018 13:31
Example for loading the splits used in "Exploring Compositional High Order Pattern Potentials for Structured Output Learning" from Li et al.
View weizman_dataset.py
# TODO: Get weizmann_32_32_trainval.mat from https://www.cs.toronto.edu/~yujiali/papers/chopps.zip
# TODO: Get horse.mat from https://www.cs.toronto.edu/~yujiali/papers/cvpr13_data.zip
# TODO: Update the paths below
split_path='YOUR_PATH_TO/weizmann_32_32_trainval.mat'
data_path='YOUR_PATH_TO/horse.mat'
# Imports
import matplotlib.pyplot as plt
import numpy as np
import scipy.io
@gyglim
gyglim / weizman_splits.json
Created December 7, 2018 12:55
Splits used Deep Value Networks Learn to Evaluate and Iteratively Refine Structured Outputs, which follows: Exploring Compositional High Order Pattern Potentials for Structured Output Learning
View weizman_splits.json
{
"test": [
"horse018.jpg",
"horse087.jpg",
"horse193.jpg",
"horse179.jpg",
"horse285.jpg",
"horse017.jpg",
"horse059.jpg",
"horse088.jpg",
@gyglim
gyglim / logging_subprocess.py
Created March 17, 2017 09:16
Wrapper around subprocess to debug moviepy OSErrors
View logging_subprocess.py
"""Wrapper around subprocess that logs the calls to Popen and tracks how many pipes are open"""
import inspect
import os
import subprocess as sp
import logging
import sys
logger = logging.getLogger('subprocess')
logger.setLevel(logging.DEBUG)
View resize_speed_test.py
from moviepy.editor import VideoFileClip
import cv2
size= (128, 128)
video_file='/home/gyglim/scratch_gygli/gifscom/shot_detection/debug_videos/UEoUURJ1Dck.mp4'
v1 = VideoFileClip(video_file, target_resolution=size, resize_algorithm='bilinear').subclip(0, 60)
def read_resized():
for f in v1.iter_frames():
pass
@gyglim
gyglim / timeout_decorator.py
Created March 8, 2017 14:36
Decorator to timeout function calls and correctly re-raise Exceptions
View timeout_decorator.py
"""Function to build timeout dectorators for specific times.
Example usage:
@timeout(1)
def x(): time.sleep(2)
x()
will raise a TimeoutException.
@gyglim
gyglim / rank_loss.py
Last active September 21, 2017 15:23
Lasagne rank loss
View rank_loss.py
def rank_loss(prediction, margin=1):
'''
Implementation of a pairwise rank loss, based on https://github.com/Lasagne/Lasagne/issues/168#issuecomment-81134242
:param prediction:
:param target_var:
:return:
'''
score_pos = prediction[0::2]
score_neg = prediction[1::2]
@gyglim
gyglim / tensorboard_logging.py
Last active October 23, 2022 11:06
Logging to tensorboard without tensorflow operations. Uses manually generated summaries instead of summary ops
View tensorboard_logging.py
"""Simple example on how to log scalars and images to tensorboard without tensor ops.
License: BSD License 2.0
"""
__author__ = "Michael Gygli"
import tensorflow as tf
from StringIO import StringIO
import matplotlib.pyplot as plt
import numpy as np