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 numpy as np | |
from skimage.data import camera | |
import matplotlib.pyplot as plt | |
img = camera().astype('float32') | |
f = (img/img.sum()).ravel() | |
p = np.cumsum(f) | |
ys = np.random.rand(500) | |
xs = np.searchsorted(p, ys) | |
buf = np.zeros(img.shape) |
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
from math import * | |
def euler2q(roll, pitch, yaw): | |
""" | |
https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles | |
""" | |
cy = cos(yaw * 0.5) | |
sy = sin(yaw * 0.5) | |
cp = cos(pitch * 0.5) | |
sp = sin(pitch * 0.5) |
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 torch | |
import torch.nn as nn | |
from torch.utils.data import Dataset, DataLoader | |
from torchvision import transforms | |
from PIL import Image as Image | |
import os | |
import pdb | |
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])]) |
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
'''This script goes along the blog post | |
"Building powerful image classification models using very little data" | |
from blog.keras.io. | |
It uses data that can be downloaded at: | |
https://www.kaggle.com/c/dogs-vs-cats/data | |
In our setup, we: | |
- created a data/ folder | |
- created train/ and validation/ subfolders inside data/ | |
- created cats/ and dogs/ subfolders inside train/ and validation/ | |
- put the cat pictures index 0-999 in data/train/cats |
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
my_list = ['geeks', 'for', 'geeks', 'like', | |
'geeky','nerdy', 'geek', 'love', | |
'questions','words', 'life'] | |
# Yield successive n-sized | |
# chunks from L. | |
def divide_chunks(L, n): | |
# looping till length l | |
for i in range(0, len(L), n): |
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 numpy as np | |
import matplotlib.pyplot as plt | |
from matplotlib.patches import Polygon | |
x = np.arange(10) | |
y = np.random.rand(10) | |
ymax = y + np.random.rand(10)/5 | |
ymin = y - np.random.rand(10)/5 | |
xy = list(zip(x, ymin)) + list(zip(x, ymax))[::-1] |