Skip to content

Instantly share code, notes, and snippets.

Avatar
☝️
One thing at a time.

Suyog Jadhav IAmSuyogJadhav

☝️
One thing at a time.
View GitHub Profile
@IAmSuyogJadhav
IAmSuyogJadhav / asus-mutemic
Created Jun 15, 2021
Refer to the blog for more info:
View asus-mutemic
event=button/micmute MICMUTE 00000080 00000000 K
action=/etc/acpi/asus-mutemic.sh
@IAmSuyogJadhav
IAmSuyogJadhav / asus-mutemic.sh
Last active Jun 15, 2021
Refer to the blog for more info:
View asus-mutemic.sh
#!/bin/sh
#sudo PULSE_RUNTIME_PATH=/var/run/pulse -u pulse pacmd list-sources | grep -oP 'index: \d+' | awk '{ print $2 }' | xargs -I{} pactl set-source-mute {} toggle
sudo PULSE_RUNTIME_PATH=/var/run/pulse -u pulse pactl set-source-mute 2 toggle && pactl set-source-mute 1 toggle && pactl set-source-mute 0 toggle
@IAmSuyogJadhav
IAmSuyogJadhav / opencv-camera-calibration-undistortion.py
Created Mar 20, 2021
A working script for calibrating and undistorting/dewarping the distortion from any regular or fisheye camera. Takes care of resizing and rescaling the FOV appropriately to get rid of the empty black space on both the sides (which is observed in case of high FOV fisheye lenses).
View opencv-camera-calibration-undistortion.py
"""
Modified version of the original script from https://github.com/mesutpiskin/opencv-fisheye-undistortion/blob/master/src/python/camera_calibration_undistortion.py
"""
import cv2
import numpy as np
import glob
def calibrate(folder, rows=6, cols=9, save_file='calibrationdata.npz'):
@IAmSuyogJadhav
IAmSuyogJadhav / number_of_parameters.py
Created Jan 12, 2021
Count and display the total no. of parameters in a PyTorch model.
View number_of_parameters.py
# model is your pytorch model (an nn.Module instance)
pytorch_total_params = sum(p.numel() for p in model.parameters())
print(pytorch_total_params)
@IAmSuyogJadhav
IAmSuyogJadhav / remove_data_parallel.py
Last active Jan 3, 2021
Remove DataParallel from PyTorch models trained with nn.DataParallel or nn.DistributedDataParallel. Input = old state_dict, output = new state_dict that works without nn.DataParallel or nn.DistributedDataParallel
View remove_data_parallel.py
def remove_data_parallel(old_state_dict):
new_state_dict = OrderedDict()
for k, v in old_state_dict.items():
name = k[7:] # remove `module.`
new_state_dict[name] = v
return new_state_dict
@IAmSuyogJadhav
IAmSuyogJadhav / gcp-ubuntu-deep-learning
Created Jul 24, 2020
Create a new instance on GCP with 1xTesla T4 GPU. Use following commands in the terminal to get started with a pyTorch installation.
View gcp-ubuntu-deep-learning
# Install CUDA Drivers (for Tesla T4)
# From https://docs.nvidia.com/datacenter/tesla/tesla-installation-notes/index.html
sudo apt-get install linux-headers-$(uname -r)
distribution=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g')
wget https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/cuda-$distribution.pin
sudo mv cuda-$distribution.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/7fa2af80.pub
echo "deb http://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda.list
sudo apt-get update
@IAmSuyogJadhav
IAmSuyogJadhav / FourierShift2D.py
Last active Apr 15, 2021
2D shifting in python. Accepts both real and complex inputs. Accepts integer as well as floating-point values for shifting. Allows for subpixel shifting of both real and complex 2D matrices/images in python. Based on: https://github.com/aludnam/MATLAB/blob/master/image_proc/FourierShift2D.m
View FourierShift2D.py
def FourierShift2D(x, delta):
"""
FourierShift2D(x, delta)
Subpixel shifting in python. Based on the original script (FourierShift2D.m)
by Tim Hutt.
Original Description
--------------------
Shifts x by delta cyclically. Uses the fourier shift theorem.
Real inputs should give real outputs.
@IAmSuyogJadhav
IAmSuyogJadhav / install_tsne-cuda.sh
Created Jan 22, 2020
Script to install tsne-CUDA by @CannyLab using conda. Derived from https://medium.com/analytics-vidhya/super-fast-tsne-cuda-on-kaggle-b66dcdc4a5a4 to work on any linux system
View install_tsne-cuda.sh
# Change CUDA version if needed
conda install faiss-gpu cudatoolkit=10.0 -c pytorch
sudo apt install libopenblas-dev
wget https://anaconda.org/CannyLab/tsnecuda/2.1.0/download/linux-64/tsnecuda-2.1.0-cuda100.tar.bz2
tar xvjf tsnecuda-2.1.0-cuda100.tar.bz2 --wildcards 'lib/*'
tar xvjf tsnecuda-2.1.0-cuda100.tar.bz2 --wildcards 'site-packages/*'
# Fill your username below. Change python version if needed
cp -r site-packages/* /home/username/anaconda3/lib/python3.7/site-packages/
@IAmSuyogJadhav
IAmSuyogJadhav / ssh-to-gcp-as-root.md
Last active Sep 6, 2019
SSH to your GCP Instance as the root user, even when outbound SSH port (22) is blocked on your local system.
View ssh-to-gcp-as-root.md

On Local System

  1. Run the following command to generate a key.
$ ssh-keygen

You'll be asked to enter passphrase. You can leave that empty.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:
@IAmSuyogJadhav
IAmSuyogJadhav / ssh-to-gcp-as-root.md
Created Sep 6, 2019
SSH to your GCP Instance as the root user.even when outbound SSH port (22) is blocked on your local system.
View ssh-to-gcp-as-root.md

On Local System

  1. Run the following command to generate a key.
$ ssh-keygen

You'll be asked to enter passphrase. You can leave that empty.

Enter passphrase (empty for no passphrase):
Enter same passphrase again: