Skip to content

Instantly share code, notes, and snippets.

View humandotlearning's full-sized avatar
💭
making world better with neural networks

nithin varghese humandotlearning

💭
making world better with neural networks
View GitHub Profile
import cv2
import os
import time
import queue
import threading
import multiprocessing
def capture_frames(url, fps, frame_save_path, video_duration=5):
try:
cap = cv2.VideoCapture(url)
#####################################################################################################
# Snippet for pytorch distributed training
######################################################################################################
import torch
from torch import nn
model = Model(input_size, output_size)
@humandotlearning
humandotlearning / docker_cheatsheet.py
Last active February 19, 2021 14:12
docker cheatsheet
# save docker in .tar.gz to save space
# this line loads a docker image from some_docker.tar.gz
sudo docker load < some_docker.tar.gz
# you can detach from a container and leave it running using the CTRL-p CTRL-q key sequence.
CTRL-p CTRL-q
####################################################################################################################
@humandotlearning
humandotlearning / custom_dataset.py
Last active May 10, 2020 22:03
pytorch tips and tricks
# https://github.com/utkuozbulak/pytorch-custom-dataset-examples
from torch.utils.data.dataset import Dataset
class ABCDataset(Dataset):
def __init__(self, csv_file_pth, img_dir):
"""
Args:
csv_file_pth (string): Path to the csv file with annotations.
img_dir (string): Directory with all the images.
@humandotlearning
humandotlearning / aws_file_transfer.sh
Last active March 1, 2021 07:31
clowd aws, gcloud sample codes
# use any FTP like fillezilla for transferring files between your comp to aws
# or use cli
sudo scp -i "aws_vpn_test.pem" -r ubuntu@ec2-3-14-73-32.us-east-2.compute.amazonaws.com:~/FR/FaceRecognition/lightning_logs/default/version_27/ ~/
@humandotlearning
humandotlearning / tf_limit_gpu.py
Created December 5, 2019 07:31
tensorflow troubleshooting and utility
# to limit the gpu usuage of tf, use the following commands
###################################################################################################
gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
# Restrict TensorFlow to only allocate 3GB of memory on the first GPU
try:
tf.config.experimental.set_virtual_device_configuration(
gpus[0],
[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=3000)])
@humandotlearning
humandotlearning / openvc_troubleshooting.py
Created October 10, 2019 14:16
opencv troubleshooting
# draw rectangle
bb_img = cv2.rectangle(img , (5, 5), (220, 220), (255, 0, 0) , 2) #image, start_point, end_point, color, thickness
@humandotlearning
humandotlearning / cuda_driver_install.sh
Last active September 19, 2019 10:53
all drivers related to cuda are installed
#!/bin/bash
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb
@humandotlearning
humandotlearning / thread_return.py
Created April 5, 2019 12:59
threading in python with return
def foo(bar):
print 'hello {0}'.format(bar)
return "foo"
# for python 2
class ThreadWithReturnValue(Thread):
def __init__(self, group=None, target=None, name=None,
args=(), kwargs={}, Verbose=None):
Thread.__init__(self, group, target, name, args, kwargs, Verbose)
self._return = None
@humandotlearning
humandotlearning / download _from_gdrive.sh
Last active February 26, 2020 11:05
installs gdrive
# to download file from gdrive create a shareable link and follow the instruction in the link
https://github.com/circulosmeos/gdown.pl