Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from sklearn.feature_extraction import image
- from scipy.misc import imread, imresize, imshow
- import matplotlib.pyplot as plt
- from PIL import Image, ImageFilter
- import os, sys
- shirts = []
- jerseys = []
- for file in os.listdir('shirts'):
- if file != ".DS_Store":
- mat = plt.imread('shirts/'+file)
- shirts.append(mat)
- for file in os.listdir('jerseys'):
- if file != ".DS_Store":
- mat = plt.imread('jerseys/'+file)
- jerseys.append(mat)
- shirts_resize = []
- jerseys_resize = []
- for shirt in shirts:
- new_shirt = imresize(shirt, (250, 200))
- shirts_resize.append(new_shirt)
- for jersey in jerseys:
- new_jersey = imresize(jersey, (250, 200))
- jerseys_resize.append(new_jersey)
- from mpl_toolkits.mplot3d import Axes3D
- from sklearn import decomposition
- shirts_ar = np.asarray(shirts_resize)
- jerseys_ar = np.asarray(jerseys_resize)
- #this reshapes it, giving it the number of
- shirts_2 = shirts_ar.reshape(200,-1)
- jerseys_2 = jerseys_ar.reshape(200,-1)
- decomposition.PCA(n_components=2)
Add Comment
Please, Sign In to add comment