Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a1c9425a65 | ||
|
a4cf816bf2 | ||
|
a6d3bd8640 |
@ -1,8 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.7 (ProjektAI)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -3,5 +3,8 @@
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (ProjektAI)" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (ProjektAI)" project-jdk-type="Python SDK" />
|
||||
<component name="PyCharmProfessionalAdvertiser">
|
||||
<option name="shown" value="true" />
|
||||
</component>
|
||||
</project>
|
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 |
@ -10,11 +10,12 @@ from kelner.src.managers.WaiterManager import WaiterManager
|
||||
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
|
||||
import time
|
||||
# import time
|
||||
|
||||
# create screen consts
|
||||
Scale = 2 # scale for all images used within project
|
||||
Scale = 1 # scale for all images used within project
|
||||
CellSize = round(50 * Scale) # pixel size of 1 square cell in the grid
|
||||
PaintOffset = CellSize # pixel size of paint offset for all drawables
|
||||
GridCountX = 15 # number of columns in grid
|
||||
@ -23,9 +24,14 @@ ScreenWidth = CellSize * GridCountX + 2 * PaintOffset # screen width in pixels
|
||||
ScreenHeight = CellSize * GridCountY + 2 * PaintOffset # screen height in pixels
|
||||
running_tasks = {'table': [], 'waiter': []}
|
||||
|
||||
|
||||
|
||||
# initialize background
|
||||
gridBoard = GridBoard(ScreenWidth, ScreenHeight)
|
||||
|
||||
|
||||
classify.join('C:/Users/Maria/Desktop/ProjektAI/kelner/src/algorithms/FoodNet/classify.py')
|
||||
|
||||
# start loading prediction model
|
||||
settings.init()
|
||||
load_model_thread = LoadModelThread()
|
||||
@ -40,7 +46,7 @@ drawableManager = DrawableCollection()
|
||||
# initialize menu manager
|
||||
menuManager = MenuManager()
|
||||
|
||||
##TESTING THE DECISION TREE
|
||||
# TESTING THE DECISION TREE
|
||||
# Testing Data
|
||||
testing_db = [
|
||||
[1, 0, 0, 0, "Kurczak"],
|
||||
|
@ -2,16 +2,15 @@ from collections import defaultdict
|
||||
from shutil import copytree, rmtree, copy
|
||||
import matplotlib.pyplot as plt
|
||||
import os
|
||||
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
|
||||
import threading
|
||||
from tensorflow.keras.models import load_model
|
||||
import kelner.src.settings as settings
|
||||
|
||||
# currently all images are not stored in repo because of big weight (5 GB)
|
||||
data_dir = 'D:\\Nauka\\Studia\\4_sem\\SztucznaInteligencja\\A_star\\CNN\\foodRecognitionCNN\\food-101\\images'
|
||||
folder_dir = 'D:\\Nauka\\Studia\\4_sem\\SztucznaInteligencja\\A_star\\CNN\\foodRecognitionCNN\\food-101'
|
||||
foods_sorted = sorted(os.listdir(data_dir))
|
||||
food_id = 0
|
||||
#data_dir = 'D:\\Nauka\\Studia\\4_sem\\SztucznaInteligencja\\A_star\\CNN\\foodRecognitionCNN\\food-101\\images'
|
||||
#folder_dir = 'D:\\Nauka\\Studia\\4_sem\\SztucznaInteligencja\\A_star\\CNN\\foodRecognitionCNN\\food-101'
|
||||
#foods_sorted = sorted(os.listdir(data_dir))
|
||||
#food_id = 0
|
||||
|
||||
|
||||
# VISUALIZE DATA #
|
||||
|
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 = '/kelner/images/dataset/macarons'
|
||||
PIZZA_DIR = '/kelner/images/dataset/pizza'
|
||||
FFRIES_DIR = '/kelner/images/dataset/ffries'
|
||||
PEAS_DIR = '/kelner/src/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))
|