Skip to content

Instantly share code, notes, and snippets.

View NISH1001's full-sized avatar
💭
Staring into the abyss...

Nish NISH1001

💭
Staring into the abyss...
View GitHub Profile
@NISH1001
NISH1001 / audio-replacer.sh
Created December 11, 2018 14:34
replace audio in video
ffmpeg -i source_video -i source_audio -c:v copy -map 0:v:0 -map 1:a:0 output_video
@NISH1001
NISH1001 / noise-reduction.md
Created December 10, 2018 05:59
Remove noise from audio track

First Create Noise Profile

This is done using ffmpeg:

ffmpeg -i source.mp3 -vn -ss 00:00:18 -t 00:00:20 noisesample.wav

Create Noise Profile for Sox

sox noisesample.wav -n noiseprof noise_profile_file
@NISH1001
NISH1001 / voronoi.py
Created December 8, 2018 04:01
Compute voronoi diagram for given list of points
# coords => List of tuple => [(x1, y1), ....(xn, yn)]
def voronoi(coords, width=800, height=800, use_max=False):
coord_matrix = np.array(coords)
X, Y = zip(*coords)
if use_max:
w, h = max(X) + 2, max(Y) + 2
else:
w, h = width, height
print("Computing voronoi diagram of size :: {}, {}".format(w, h))
@NISH1001
NISH1001 / colorized_voronoi.py
Created December 7, 2018 01:22 — forked from pv/colorized_voronoi.py
Colorized Voronoi diagram with Scipy, in 2D, including infinite regions
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Voronoi
def voronoi_finite_polygons_2d(vor, radius=None):
"""
Reconstruct infinite voronoi regions in a 2D diagram to finite
regions.
Parameters
@NISH1001
NISH1001 / splitter.py
Created November 24, 2018 14:45
Create train-test directories
#!/usr/bin/env python3
import glob
from collections import defaultdict
import shutil
import os
def create_dir(dirname):
if not os.path.isdir(dirname):
os.mkdir(dirname)
@NISH1001
NISH1001 / time-lapse.md
Last active December 10, 2018 16:50
Convert sequence of image files into video.

Convert sequence of image files into video.
The image filepaths are inside "files.txt" with each line representing.

mencoder -nosound -noskip -oac copy -ovc copy -o output.avi -mf fps=6 'mf://@files.txt'
@NISH1001
NISH1001 / oasis.py
Created November 19, 2018 06:06 — forked from gwtaylor/oasis.py
""" Python implementation of the OASIS algorithm.
Graham Taylor
Based on Matlab implementation of:
Chechik, Gal, et al.
"Large scale online learning of image similarity through ranking."
The Journal of Machine Learning Research 11 (2010): 1109-1135.
"""
from __future__ import division
@NISH1001
NISH1001 / keras_tensor_dist.py
Created November 15, 2018 07:55
Compute Distances between Keras tensors
def euclidean_distance(vects):
x, y = vects
sum_square = K.sum(K.square(x - y), axis=1, keepdims=True)
return K.sqrt(K.maximum(sum_square, K.epsilon()))
def eucl_dist_output_shape(shapes):
shape1, shape2 = shapes
return (shape1[0], 1)
def cosine_distance(vests):
@NISH1001
NISH1001 / docker.md
Last active December 10, 2019 04:55
Docker barebone configurations

build docker image

docker build -t <imagename> .

example

docker build -t testapi
@NISH1001
NISH1001 / curl.sh
Created November 1, 2018 16:38
curl requests
# POST simple text
curl -XPOST localhost:8000/test --data "i am paradox" -H "Content-Type: text/plain"
# POST JSON
# GET
curl -XGET localhost:8000/test