Skip to content

Instantly share code, notes, and snippets.

View 0HaNC's full-sized avatar

Hanxi Lin 0HaNC

  • Beijing Institute of Technology
View GitHub Profile
@etienne87
etienne87 / HogLayer.py
Last active March 23, 2024 16:36
Histogram-of-Oriented Gradient in Pytorch in 10 minutes
import torch
import torch.nn as nn
import torch.nn.functional as F
import math
import time
def timeit(x, func, iter=10):
torch.cuda.synchronize()
start = time.time()
@AruniRC
AruniRC / video_frames.py
Created July 17, 2018 16:56
Get number of frames using Scikit-video and Python
'''
Sometimes it is useful to know the total number of video frames before starting to iterate.
This is not possible using the default video reader in Sk-video.
The snippet below shows how to do this using the FFMPEG reader instead.
'''
if osp.exists(video_path):
vid_reader = skvideo.io.FFmpegReader(video_path) # NOTE: not the standard skvideo.io.vreader
else:
raise IOError('Path to video not found: \n%s' % video_path)