Guest User

Untitled

a guest
Feb 24th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import numpy as np
  2. from sklearn.feature_extraction import image
  3. from scipy.misc import imread, imresize, imshow
  4. import matplotlib.pyplot as plt
  5. from PIL import Image, ImageFilter
  6. import os, sys
  7.  
  8. shirts = []
  9. jerseys = []
  10.  
  11. for file in os.listdir('shirts'):
  12. if file != ".DS_Store":
  13. mat = plt.imread('shirts/'+file)
  14. shirts.append(mat)
  15.  
  16. for file in os.listdir('jerseys'):
  17. if file != ".DS_Store":
  18. mat = plt.imread('jerseys/'+file)
  19. jerseys.append(mat)
  20.  
  21. shirts_resize = []
  22. jerseys_resize = []
  23.  
  24. for shirt in shirts:
  25. new_shirt = imresize(shirt, (250, 200))
  26. shirts_resize.append(new_shirt)
  27.  
  28. for jersey in jerseys:
  29. new_jersey = imresize(jersey, (250, 200))
  30. jerseys_resize.append(new_jersey)
  31.  
  32. from mpl_toolkits.mplot3d import Axes3D
  33. from sklearn import decomposition
  34.  
  35. shirts_ar = np.asarray(shirts_resize)
  36. jerseys_ar = np.asarray(jerseys_resize)
  37.  
  38. #this reshapes it, giving it the number of
  39. shirts_2 = shirts_ar.reshape(200,-1)
  40. jerseys_2 = jerseys_ar.reshape(200,-1)
  41.  
  42. decomposition.PCA(n_components=2)
Add Comment
Please, Sign In to add comment