Skip to content

Instantly share code, notes, and snippets.

Avatar

Uzzal Podder uzl

View GitHub Profile
@uzl
uzl / cropping_char.py
Created Feb 18, 2020
Cropping important part
View cropping_char.py
from pathlib import Path
from pprint import pprint
import cv2
import numpy as np
import matplotlib.pyplot as plt
import concurrent
from tqdm import tqdm
# Just for visualization. By default it is inactive
def display_img(img_list):
@uzl
uzl / BCELoss_testing.py
Created Jan 16, 2020
BCELoss Testing with custom input
View BCELoss_testing.py
import torch
y_pred = torch.tensor([
[1, 1, 0, 1, 1, 1]
], dtype=torch.float)
y_truth_id = torch.tensor([2], dtype=torch.long)
y_truth_id_tmp = y_truth_id.unsqueeze(0)
y_truth_one_hot = torch.zeros(y_truth_id_tmp.size(0), 6).scatter_(1, y_truth_id_tmp, 1.)
@uzl
uzl / docker history
Created Sep 26, 2019
To generate the docker file, docker history can be used.
View docker history
docker history --no-trunc c3555fec4fe6 $argv | tac | tr -s ' ' | cut -d " " -f 5- | sed 's,^/bin/sh -c #(nop) ,,g' | sed 's,^/bin/sh -c,RUN,g' | sed 's, && ,\n & ,g' | sed 's,\s*[0-9]*[\.]*[0-9]*[kMG]*B\s*$,,g' | head -n -1
@uzl
uzl / docker history.sh
Last active Sep 26, 2019
To generate the docker file, docker history can be used.
View docker history.sh
docker history --no-trunc c3555fec4fe6 $argv | tac | tr -s ' ' | cut -d " " -f 5- | sed 's,^/bin/sh -c #(nop) ,,g' | sed 's,^/bin/sh -c,RUN,g' | sed 's, && ,\n & ,g' | sed 's,\s*[0-9]*[\.]*[0-9]*[kMG]*B\s*$,,g' | head -n -1
@uzl
uzl / get_usb_camera_id_for_opencv.py
Created Jul 2, 2019
get usb camera id automatically for opencv
View get_usb_camera_id_for_opencv.py
def get_usb_camera_id():
from subprocess import check_output
out = check_output(["ls /dev/video*"], shell=True)
out = out.decode('utf-8').strip().split('\n')
if len(out) == 0:
raise Exception('No camera Module Found')
cam_id = None
for dev in out:
@uzl
uzl / nvidia_driver_install_ubuntu_18.md
Last active Aug 3, 2020
Install Latest Nvidia Driver in Ubuntu 18.04
View nvidia_driver_install_ubuntu_18.md

Install Latest Nvidia Driver in Ubuntu 18.04 LTS

Step: 1

Remove previous installation

sudo apt-get purge nvidia*
sudo apt-get autoremove 

@uzl
uzl / generate_distribution.py
Created May 22, 2019
Generate number array based on a range, std and mean condition
View generate_distribution.py
import numpy as np
import scipy.stats
from pprint import pprint
import matplotlib.pyplot as plt
import logging
logging.basicConfig(level=logging.DEBUG)
# source: https://stackoverflow.com/a/50629604/4257991
def my_distribution(min_val, max_val, mean, std):
scale = max_val - min_val
@uzl
uzl / plot_multiple_image.py
Last active Feb 6, 2020
Plot multiple image in Matplotlib
View plot_multiple_image.py
def my_plot(img_list):
fig = plt.figure(figsize=(8, 8))
plt.tight_layout()
sqr_arm = round(math.ceil(math.sqrt(len(img_list))))
print(sqr_arm)
columns, rows = sqr_arm, sqr_arm
for i, data in enumerate(img_list):
img, title = data if (isinstance(data, tuple) or isinstance(data, list)) else (data, '')
ax = plt.subplot(rows, columns, i+1)
@uzl
uzl / jupyter_cmds.md
Last active May 13, 2019
Jupyter Notebook commands
View jupyter_cmds.md

Run remote jupyter in localhost using ssh tunnel

in remote server

jupyter notebook --no-browser --port=8889

in local server

@uzl
uzl / my_git.md
Last active Apr 26, 2019
Useful git CLI
View my_git.md

Upload a new local repository to gitlab

This will create a new project on Gitlab without creating it manually on the server

git push --set-upstream address/your-project.git

Changing/Switching remote URLs

You can’t perform that action at this time.