Skip to content

Instantly share code, notes, and snippets.

View prerakmody's full-sized avatar
🏠
Working from home

pmod prerakmody

🏠
Working from home
View GitHub Profile
@prerakmody
prerakmody / pytorch_gpu_check.py
Last active March 8, 2019 08:53
Tensorflow GPU Check (Ubuntu) (Jupyter Notebook)
import pytorch
use_gpu = torch.cuda.is_available()
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.conv1 = nn.Conv2d(1, 6, 3, padding=1)
self.pool = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(6, 16, 3, padding=1)
@prerakmody
prerakmody / aws_deeplearning_ami.md
Last active June 25, 2018 14:46 — forked from asimihsan/setup.md
Installing Deep Learning tools on a cloud instance

Launch an EC2 Instance

  1. Check Spot Instance Pricing here
  2. Open EC2 console
  3. Choose AMI :
    • Deep Learning AMI (Ubuntu) Version 8.0 - ami-dff741a0
      • contains TensorFlow and other famous DL libraries
      • make sure you select the "Ubuntu" version and not "Amazon Linux" version
  4. Instance Type : Select an instanct type from the p2/p3 family
    • For inference purposes - p2.xlarge (1 x Nvidia Tesla K80)
  • For training purposes - p3.xlarge (1 x Nvidia Tesla V100)
@prerakmody
prerakmody / .gitignore
Created December 5, 2017 08:33
extensions and folder names to "disinclude" from git commits
# System Created
*/.ipynb_checkpoints/*
*/__pycache__/*
*.pyc
# Image Formats
*.jpg
*.jpeg
*.png
@prerakmody
prerakmody / download_gdrive.py
Last active February 5, 2023 16:19
Download open files from GDrive
import sys, time
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
return None
@prerakmody
prerakmody / ports_ubuntu.md
Last active September 14, 2021 14:08
Useful Ubuntu Commands

PORTS

  1. Checking the process running on a port
    • lsof -i :<port_number>
    • sudo netstat -peanut | grep <port_number>
  2. Checking processes
    • ps aux | grep <process_name>

LOGS

  1. Checking logs of various processes
  • tail -f /var/log/<>.log
@prerakmody
prerakmody / arrows.py
Last active August 10, 2021 13:45
Matplotlib Techniques
import matplotlib.pyplot as plt
plt.xlim([-1,20])
plt.ylim([-1,20])
plt.arrow(0, 0, 10, 10,head_width=0.5, head_length=0.5)
plt.arrow(10,10, 8,4,head_width=0.5, head_length=0.5)
@prerakmody
prerakmody / rosbag_velodyne.py
Last active February 28, 2018 15:11
Reading a ROS (Robot Operating System) datadump (.rosbag) for Velodyne LIDAR pakets
"""
Installing Rosbag
- http://wiki.ros.org/lunar/Installation
RosBag Python API
- http://wiki.ros.org/rosbag/Cookbook
- http://wiki.ros.org/rosbag/Code%20API
ROS : Velodyne PointCloud
- to convert velodyne_msgs/VelodyneScan messages to sensor_msgs/PointCloud2
@prerakmody
prerakmody / resize_ubuntu.md
Last active March 7, 2018 13:37
Command to resize a file system

lsblk_prev

lsblk_post

df_h

import os
import numpy as np
from sklearn.metrics import log_loss
"""
- HARDCODED FORMULAE
- In this gist, we shall almost always use probabilities and not unscaled logits
"""
## BINARY CLASS CROSS ENTROPY
y_true = [0,0,0,1] # 4 observations
img_url = '/home/play/data/GOD_DATASET/open_datasets/cityscapes/gtFine_trainvaltest/gtFine/train/aachen/aachen_000000_000019_gtFine_color.png'
# img_url = '/home/play/data/GOD_DATASET/open_datasets/mapillary/mapillary-vistas-dataset_public_v1.0/training/instances/QOJJHmXYAiRVW3rDK3gs0g.png'
import cv2
import skimage.io
import numpy as np
img = cv2.imread(img_url,cv2.IMREAD_UNCHANGED)
print ('\nCV2 : ', np.unique(img))