This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################################################### | |
# Snippet for pytorch distributed training | |
###################################################################################################### | |
import torch | |
from torch import nn | |
model = Model(input_size, output_size) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
#################################################################################################################### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/ ~/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# draw rectangle | |
bb_img = cv2.rectangle(img , (5, 5), (220, 220), (255, 0, 0) , 2) #image, start_point, end_point, color, thickness |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to download file from gdrive create a shareable link and follow the instruction in the link | |
https://github.com/circulosmeos/gdown.pl |
NewerOlder