Remove previous installation
sudo apt-get purge nvidia*
sudo apt-get autoremove
import torch.nn as nn | |
import torch.nn.functional as F | |
from torch.backends.cuda import sdp_kernel, SDPBackend | |
import time | |
import torch | |
import torch.utils.benchmark as benchmark | |
# check dependency | |
assert torch.cuda.is_available(), 'CUDA is expected.' |
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): |
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.) |
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 |
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 |
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: |
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 |
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) |