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 / yolo.py
Created September 20, 2018 11:02
python wrapper over YOLO
from ctypes import *
import math
import random
def sample(probs):
s = sum(probs)
probs = [a/s for a in probs]
r = random.uniform(0, 1)
for i in range(len(probs)):
r = r - probs[i]
@NISH1001
NISH1001 / 00-keyboard.conf
Created September 21, 2018 04:29
keyboard layout config for linux
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbLayout" "us,np"
Option "XkbModel" "pc104"
Option "XkbVariant" ",dvorak"
Option "XkbOptions" "grp:lwin_toggle"
EndSection
# put this file in /etc/X11/xorg.conf.d/
@NISH1001
NISH1001 / cuda-tf-keras.md
Created October 4, 2018 08:58
A note on how we can train different models in different gpu in parallel

Method 1

First of all, we have tf.device thing that tensorflow has to offer for us to choose which gpu we want. Like:

with tf.device('/gpu:0'):
    a = tf.constant(3.0)

This allocates for gpu 0.

Method 2

@NISH1001
NISH1001 / chromium-app-luncher.md
Created October 6, 2018 02:47
Lunch chromium app directly withou opening the browser

First get the app id

  • Go to the pat h/home/paradox/.local/share/applications/
  • When you open each file, you will see the texts in following format:
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=ScreenMeter Time Tracker
@NISH1001
NISH1001 / drive-wget.sh
Last active November 29, 2019 04:46
Get drive files using wget
#wget --load-cookies /tmp/cookies.txt "https://drive.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://drive.google.com/uc?export=download&id=<FILEID>' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=<FILEID>" -O <FILENAME> && rm -rf /tmp/cookies.txt
#/usr/bin/env bash
echo "i am paradox"
FILEID="1hJKCb4eF1AJih_dhZOJSF5VR-ZtRNaap"
FILENAME="model.zip"
link="https://drive.google.com/uc?export=download&id=$FILEID"
@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
@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 / 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 / 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 / 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'