pipeline model chooser working, server predictor working

This commit is contained in:
arnaucode
2017-11-29 18:22:09 +01:00
parent 26f61c02f5
commit 950c6b4c57
207 changed files with 1168 additions and 449 deletions

2
other/imagesToDataset/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
object
noobject

View File

@@ -0,0 +1,37 @@
# imagesToDataset
Gets all the images from the directories 'object' and 'noobject', and puts in a dataset file.
The dataset file is a dataset.data file that contains 2 columns:
- images arrays of pixels
- 0 or 1, depending if is from the 'noobject' or 'object' directory
First, install the libraries.
### install scikit-learn
http://scikit-learn.org/stable/install.html
pip install -U scikit-learn
### install scikit-image
http://scikit-image.org/download
pip install -U scikit-image
### install numpy
https://www.scipy.org/install.html
python -m pip install --upgrade pip
pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
### install Pillow
http://pillow.readthedocs.io/en/3.0.x/installation.html
(sudo) pip install Pillow
### install matplotlib
https://matplotlib.org/users/installing.html
python -mpip install -U pip
python -mpip install -U matplotlib
may need to install python-tk:
sudo apt-get install python-tk
## to run
python readDataset.py

Binary file not shown.

View File

@@ -0,0 +1,54 @@
from os import walk
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image, ImageOps
import pandas as pd
#pixels, pixels of the output resizing images
size = 100, 100
def imgFileToData(path):
image = Image.open(path)
#resize the image
thumb = ImageOps.fit(image, size, Image.ANTIALIAS)
image_data = np.asarray(thumb)
#.flatten()
#check if the image had been resized to 100x100. 3pixels * 100width + 100 height = 30000
if len(image_data)!=100:
print("possible future ERROR!")
print("len: " + str(len(image_data)))
print("please, delete: " + path)
return np.array(list(image_data))
def getDirectoryFiles(path, imgClass):
images = []
for (dirpath, dirnames, filenames) in walk(path):
for filename in filenames:
#print(filename)
image_data = imgFileToData(path + "/" + filename)
images.append([image_data, imgClass])
print(path + "/" + filename)
return images
objects = getDirectoryFiles("object", 1)
noobjects = getDirectoryFiles("noobject", 0)
dataset = np.concatenate((objects, noobjects), axis=0)
#print(dataset[0])
np.save('dataset.npy', dataset)
'''
print(dataset)
np.savetxt('dataset.csv', dataset, delimiter=",", fmt='%d')
pd.set_option('display.max_colwidth', -1)
df = pd.DataFrame(dataset)
print(df.head())
print("aaa")
print(df[0][0])
print("aaa")
pd.set_option('display.max_colwidth', -1)
pd.set_option('display.max_columns', None)
df.to_csv("dataset.csv", encoding='utf-8', index=False, header=False)
'''

View File

@@ -0,0 +1,16 @@
import matplotlib.pyplot as plt
import numpy as np
from random import randint
dataset = np.load('dataset.npy')
n = randint(0, len(dataset))
plt.plot(111)
plt.axis('off')
plt.imshow(dataset[n][0])
plt.title('class: ' + str(dataset[n][1]))
plt.show()