Food clasification network
@ -4,7 +4,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.8 (ProjektAI) (2)" jdkType="Python SDK" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.7 (ProjektAI)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -3,5 +3,5 @@
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (ProjektAI) (2)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (ProjektAI)" project-jdk-type="Python SDK" />
|
||||
</project>
|
BIN
Raport - Podprojekt Adam Toppmayer.pdf
Normal file
BIN
Raport - Podprojekt_Adam_Wojdyla.pdf
Normal file
BIN
Raport - Podprojekt_Mariia_Kuzmenko.pdf
Normal file
BIN
Raport - _Automatyczny kelner_.pdf
Normal file
BIN
Raport 2 - _Automatyczny kelner_.pdf
Normal file
BIN
kelner/images/dataset/ffries/10500.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
kelner/images/dataset/ffries/17394.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
kelner/images/dataset/ffries/20215.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
kelner/images/dataset/ffries/24479.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
kelner/images/dataset/ffries/43636.jpg
Normal file
After Width: | Height: | Size: 75 KiB |
BIN
kelner/images/dataset/ffries/48052.jpg
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
kelner/images/dataset/ffries/51368.jpg
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
kelner/images/dataset/ffries/51678.jpg
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
kelner/images/dataset/ffries/52510.jpg
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
kelner/images/dataset/ffries/57594.jpg
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
kelner/images/dataset/macarons/1075.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
kelner/images/dataset/macarons/15110.jpg
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
kelner/images/dataset/macarons/15274.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
kelner/images/dataset/macarons/17515.jpg
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
kelner/images/dataset/macarons/28826.jpg
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
kelner/images/dataset/macarons/30074.jpg
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
kelner/images/dataset/macarons/305.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
kelner/images/dataset/macarons/50327.jpg
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
kelner/images/dataset/macarons/67737.jpg
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
kelner/images/dataset/macarons/70102.jpg
Normal file
After Width: | Height: | Size: 47 KiB |
BIN
kelner/images/dataset/peas/11883.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
kelner/images/dataset/peas/17431.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
kelner/images/dataset/peas/17923.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
kelner/images/dataset/peas/17928.jpg
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
kelner/images/dataset/peas/19123.jpg
Normal file
After Width: | Height: | Size: 23 KiB |
BIN
kelner/images/dataset/peas/20934.jpg
Normal file
After Width: | Height: | Size: 71 KiB |
BIN
kelner/images/dataset/peas/42964.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
kelner/images/dataset/peas/4321.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
kelner/images/dataset/peas/5531.jpg
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
kelner/images/dataset/peas/5615.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
kelner/images/dataset/pizza/11297.jpg
Normal file
After Width: | Height: | Size: 84 KiB |
BIN
kelner/images/dataset/pizza/2965.jpg
Normal file
After Width: | Height: | Size: 68 KiB |
BIN
kelner/images/dataset/pizza/34632.jpg
Normal file
After Width: | Height: | Size: 69 KiB |
BIN
kelner/images/dataset/pizza/40449.jpg
Normal file
After Width: | Height: | Size: 90 KiB |
BIN
kelner/images/dataset/pizza/53217.jpg
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
kelner/images/dataset/pizza/54540.jpg
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
kelner/images/dataset/pizza/56449.jpg
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
kelner/images/dataset/pizza/5764.jpg
Normal file
After Width: | Height: | Size: 64 KiB |
BIN
kelner/images/dataset/pizza/59445.jpg
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
kelner/images/dataset/pizza/8917.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
@ -11,6 +11,7 @@ from kelner.src.managers.TableGenerator import TableGenerator
|
||||
from kelner.src.algorithms.DecisionTree import Tree_Builder
|
||||
from kelner.src.managers.KitchenManager import KitchenManager
|
||||
from kelner.src.algorithms.CNN.PrepareData import LoadModelThread
|
||||
from kelner.src.algorithms.FoodNet import classify
|
||||
import kelner.src.settings as settings
|
||||
|
||||
Scale = 1.5 # scale for all images used within project
|
||||
@ -25,6 +26,8 @@ running_tasks = {'table': [], 'waiter': []}
|
||||
# initialize background
|
||||
gridBoard = GridBoard(ScreenWidth, ScreenHeight)
|
||||
|
||||
classify.join('/src/algorithms/FoodNet/classify.py')
|
||||
|
||||
# start loading prediction model
|
||||
settings.init()
|
||||
load_model_thread = LoadModelThread()
|
||||
|
99
kelner/src/algorithms/FoodNet/classify.py
Normal file
@ -0,0 +1,99 @@
|
||||
import tensorflow as tf
|
||||
from PIL import Image
|
||||
import sys, numpy
|
||||
from os import listdir
|
||||
from os.path import isfile, join
|
||||
from tensorflow import keras
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
MACARONS_DIR = './././images/dataset/macarons'
|
||||
PIZZA_DIR = './././images/dataset/pizza'
|
||||
FFRIES_DIR = './././images/dataset/ffries'
|
||||
PEAS_DIR = './././images/dataset/peas'
|
||||
COUNT = 10
|
||||
SIZE = 128, 128
|
||||
|
||||
def getFileList(folder):
|
||||
return [f for f in listdir(folder) if isfile(join(folder, f))]
|
||||
|
||||
def conv(arr):
|
||||
res = []
|
||||
for i in arr:
|
||||
res.append([j[0] for j in i])
|
||||
return numpy.array(res)
|
||||
|
||||
def getArray(filename):
|
||||
pic = Image.open(filename).convert('LA').resize(SIZE, Image.ANTIALIAS)
|
||||
return numpy.array([conv(numpy.array(pic)) / 255.0])
|
||||
|
||||
|
||||
macaronsImages = getFileList(MACARONS_DIR)
|
||||
pizzaImages = getFileList(PIZZA_DIR)
|
||||
ffriesImages = getFileList(FFRIES_DIR)
|
||||
peasImages = getFileList(PEAS_DIR)
|
||||
train_images = []
|
||||
train_labels = []
|
||||
test_images = []
|
||||
test_labels = []
|
||||
|
||||
for i in range(COUNT):
|
||||
pic = Image.open(MACARONS_DIR + '/' + macaronsImages[i]).convert('LA').resize(SIZE, Image.ANTIALIAS)
|
||||
train_images.append(conv(numpy.array(pic)) / 255.0)
|
||||
train_labels.append(0)
|
||||
if i < COUNT / 10:
|
||||
test_images.append(conv(numpy.array(pic)) / 255.0)
|
||||
test_labels.append(0)
|
||||
pic = Image.open(PIZZA_DIR + '/' + pizzaImages[i]).convert('LA').resize(SIZE, Image.ANTIALIAS)
|
||||
train_images.append(conv(numpy.array(pic)) / 255.0)
|
||||
train_labels.append(1)
|
||||
if i < COUNT / 10:
|
||||
test_images.append(conv(numpy.array(pic)) / 255.0)
|
||||
test_labels.append(1)
|
||||
pic = Image.open(FFRIES_DIR + '/' + ffriesImages[i]).convert('LA').resize(SIZE, Image.ANTIALIAS)
|
||||
train_images.append(conv(numpy.array(pic)) / 255.0)
|
||||
train_labels.append(2)
|
||||
if i < COUNT / 10:
|
||||
test_images.append(conv(numpy.array(pic)) / 255.0)
|
||||
test_labels.append(2)
|
||||
pic = Image.open(PEAS_DIR + '/' + peasImages[i]).convert('LA').resize(SIZE, Image.ANTIALIAS)
|
||||
train_images.append(conv(numpy.array(pic)) / 255.0)
|
||||
train_labels.append(3)
|
||||
if i < COUNT / 10:
|
||||
test_images.append(conv(numpy.array(pic)) / 255.0)
|
||||
test_labels.append(3)
|
||||
|
||||
train_i = numpy.array(train_images)
|
||||
train_l = numpy.array(train_labels)
|
||||
test_i = numpy.array(test_images)
|
||||
test_l = numpy.array(test_labels)
|
||||
|
||||
|
||||
class_names = ['macarons', 'pizza', 'ffries', 'peas']
|
||||
|
||||
model = keras.Sequential([
|
||||
keras.layers.Flatten(input_shape=SIZE),
|
||||
keras.layers.Dense(128, activation=tf.nn.relu),
|
||||
keras.layers.Dense(4, activation=tf.nn.softmax)
|
||||
])
|
||||
|
||||
|
||||
model.compile(optimizer=tf.compat.v1.train.AdamOptimizer(),
|
||||
loss='sparse_categorical_crossentropy',
|
||||
metrics=['accuracy'])
|
||||
|
||||
|
||||
|
||||
model.fit(train_i, train_l, epochs=15)
|
||||
|
||||
test_loss, test_acc = model.evaluate(test_i, test_l)
|
||||
print('Test accuracy:', test_acc)
|
||||
|
||||
predictions = model.predict(test_i)
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
predictions = model.predict([getArray(sys.argv[1])])
|
||||
if numpy.max(predictions) > 0.5:
|
||||
print(class_names[numpy.argmax(predictions)])
|
||||
else:
|
||||
print('mix')
|
||||
print(numpy.max(predictions))
|