diff --git a/app.py b/app.py
index 6e7c6d9..d18e2b5 100644
--- a/app.py
+++ b/app.py
@@ -11,10 +11,10 @@ import threading
import time
import random
from classes.data.klient import Klient
-from classes.data.klient import Klient
+from classes.data.klient import KlientCechy
import xml.etree.ElementTree as ET
from decisiontree import predict_client
-
+from classes.Jimmy_Neuron.predict_image import predict_image
pygame.init()
window = pygame.display.set_mode((prefs.WIDTH, prefs.HEIGHT))
@@ -102,9 +102,8 @@ agent = Agent(prefs.SPAWN_POINT[0], prefs.SPAWN_POINT[1], cells)
klient = Klient(prefs.GRID_SIZE-1, 17,cells)
target_x, target_y = klientx_target-1, klienty_target
-
-
def watekDlaSciezkiAgenta():
+ assigned = False
time.sleep(3)
while True:
if len(path) > 0:
@@ -119,10 +118,26 @@ def watekDlaSciezkiAgenta():
elif isinstance(element, tuple): # Check if it's a tuple indicating movement coordinates
x, y = element
agent.moveto(x, y)
+
+ neighbors = agent.get_neighbors(agent.current_cell, agent.cells)
+ for neighbor in neighbors:
+ if neighbor == klient.current_cell:
+ if not assigned:
+ random_client_data = random.choice(clients)
+ glasses = predict_image(random_client_data.zdjecie)
+ prediction = predict_client(random_client_data, glasses)
+ print("\nClient data:")
+ print(random_client_data)
+ print("Prediction (Adult):", prediction)
+ assigned = True
+ break
+ if assigned:
+ break
+
+
time.sleep(1)
def watekDlaSciezkiKlienta():
- assigned = False
time.sleep(3)
while True:
if len(path2) > 0:
@@ -138,20 +153,12 @@ def watekDlaSciezkiKlienta():
x, y = element2
klient.moveto(x, y)
- if not assigned and klient.current_cell == cells[klientx_target][klienty_target]:
+ if klient.current_cell == cells[klientx_target][klienty_target]:
klient.przyStoliku = True
klient.stolik = klient.current_cell
- random_client_data = random.choice(clients)
- prediction = predict_client(random_client_data)
- print("\nClient data:")
- print(random_client_data)
- print("Prediction (Adult):", prediction)
- assigned = True
-
- if assigned:
- break
time.sleep(1)
+
path2 = klient.bfs2(klientx_target, klienty_target)
print("Najkrótsza ścieżka:", path2)
@@ -165,6 +172,7 @@ watek = threading.Thread(target=watekDlaSciezkiAgenta)
watek.daemon = True
watek.start()
+
running = True
while running:
for event in pygame.event.get():
diff --git a/classes/Jimmy_Neuron/predict_image.py b/classes/Jimmy_Neuron/predict_image.py
new file mode 100644
index 0000000..3aa262d
--- /dev/null
+++ b/classes/Jimmy_Neuron/predict_image.py
@@ -0,0 +1,36 @@
+import torch
+from torchvision.transforms import Compose, Lambda
+import torchvision.io as io
+
+device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
+
+hidden_size = 135 * 64
+model = torch.nn.Sequential(
+ torch.nn.Conv2d(3, 6, 5),
+ torch.nn.MaxPool2d(2, 2),
+ torch.nn.Conv2d(6, 16, 5),
+ torch.nn.Flatten(),
+ torch.nn.Linear(53824, hidden_size),
+ torch.nn.ReLU(),
+ torch.nn.Linear(hidden_size, 32 * 32),
+ torch.nn.ReLU(),
+ torch.nn.Linear(32 * 32, 10),
+ torch.nn.LogSoftmax(dim=-1)
+).to(device)
+
+model.load_state_dict(torch.load('model.pt', map_location=device))
+model.eval()
+
+def predict_image(image_path):
+ transform = Compose([Lambda(lambda x: x.float())])
+ image = io.read_image(image_path, mode=io.ImageReadMode.UNCHANGED)
+ image = transform(image)
+ image = image.unsqueeze(0)
+ image = image.to(device)
+ with torch.no_grad():
+ output = model(image)
+ predicted_class = output.argmax(dim=1).item()
+ print(predicted_class)
+
+ return predicted_class
+
diff --git a/classes/agent.py b/classes/agent.py
index fde3351..2be02c4 100644
--- a/classes/agent.py
+++ b/classes/agent.py
@@ -275,6 +275,8 @@ class Agent:
dx = abs(current[0] - target[0])
dy = abs(current[1] - target[1])
return dx + dy
+
+
diff --git a/classes/data/data_initializer.py b/classes/data/data_initializer.py
index 9deebb2..0d8b958 100644
--- a/classes/data/data_initializer.py
+++ b/classes/data/data_initializer.py
@@ -85,8 +85,8 @@ for person in root.findall('person'):
outfit_element = person.find('Outfit')
outfit = outfit_element.text if outfit_element is not None else ''
- glasses_element = person.find('Glasses')
- glasses = glasses_element.text if glasses_element is not None else ''
+ image_element = person.find('Image')
+ image = image_element.text if image_element is not None else ''
tattoo_element = person.find('Tattoo')
tattoo = tattoo_element.text if tattoo_element is not None else ''
@@ -107,10 +107,10 @@ for person in root.findall('person'):
'lysienie': balding,
'broda': beard,
'ubior': outfit,
- 'okulary': glasses,
'tatuaz': tattoo,
'wlosy': hair,
- 'zachowanie': behaviour
+ 'zachowanie': behaviour,
+ 'zdjecie': image
}
clients.append(KlientCechy(**person_data))
diff --git a/classes/data/klient.py b/classes/data/klient.py
index 6cf7c60..dac2eab 100644
--- a/classes/data/klient.py
+++ b/classes/data/klient.py
@@ -14,7 +14,7 @@ class Klient:
self.current_cell = cells[x][y]
self.current_x = x
self.current_y = y
- przyStoliku = False
+ self.przyStoliku = False
self.cells = cells
self.X = x
self.Y = y
@@ -183,7 +183,7 @@ class Klient:
class KlientCechy:
- def __init__(self,imie,nazwisko,wiek,ulubiony_posilek,restrykcje_dietowe,zmarszczki, lysienie, broda, ubior, okulary, tatuaz, wlosy, zachowanie):
+ def __init__(self,imie,nazwisko,wiek,ulubiony_posilek,restrykcje_dietowe,zmarszczki, lysienie, broda, ubior, tatuaz, wlosy, zachowanie, zdjecie):
self.imie = imie
self.nazwisko = nazwisko
self.wiek = wiek
@@ -193,7 +193,7 @@ class KlientCechy:
self.lysienie = lysienie
self.broda = broda
self.ubior = ubior
- self.okulary = okulary
+ self.zdjecie = zdjecie
self.tatuaz = tatuaz
self.wlosy = wlosy
self.zachowanie = zachowanie
@@ -210,4 +210,4 @@ class KlientCechy:
print("Klient ma juz przypisany stolik.")
def __str__(self):
- return f"Klient: {self.imie} {self.nazwisko} {self.wiek}, ulubione Danie: {self.ulubiony_posilek}, restrykcje diet: {self.restrykcje_dietowe}. Jego cechy to: zmarszczki: {self.zmarszczki}, lysienie: {self.lysienie}, broda: {self.broda}, ubior: {self.ubior}, okulary: {self.okulary}, tatuaz: {self.tatuaz}, wlosy: {self.wlosy}, zachowanie: {self.zachowanie}"
+ return f"Klient: {self.imie} {self.nazwisko} {self.wiek}, ulubione Danie: {self.ulubiony_posilek}, restrykcje diet: {self.restrykcje_dietowe}. Jego cechy to: zmarszczki: {self.zmarszczki}, lysienie: {self.lysienie}, broda: {self.broda}, ubior: {self.ubior}, tatuaz: {self.tatuaz}, wlosy: {self.wlosy}, zachowanie: {self.zachowanie}"
diff --git a/database/clients.xml b/database/clients.xml
index 098221b..86b5022 100644
--- a/database/clients.xml
+++ b/database/clients.xml
@@ -6,13 +6,14 @@
Tatar
Meat
No
- Yes
- Yes
+ No
+ No
Messy
- No
+ Yes
No
- Color
+ Natural
Energetic
+ database\\clientsimg\\DavidBowie.png
Kamil
@@ -23,11 +24,12 @@
No
No
No
- Messy
+ Casual
No
No
- Color
+ Natural
Energetic
+ database\\clientsimg\\DavidBowie.png
Jon
@@ -36,14 +38,15 @@
Grochówka
Vegan
No
- No
- No
+ Yes
+ Yes
Messy
No
- No
+ Yes
Color
- Energetic
-
+ Stressed
+ database\\clientsimg\\DavidBowie.png
+
Andrzej
Kowalski
@@ -52,11 +55,12 @@
Meat
No
No
- No
- Messy
- No
+ Yes
+ Formal
+ Yes
No
- Color
- Energetic
+ Grey
+ Calm
+ database\\clientsimg\\AndrzejKowalski.png
\ No newline at end of file
diff --git a/database/clientsimg/AndrzejKowalski.png b/database/clientsimg/AndrzejKowalski.png
new file mode 100644
index 0000000..723c850
Binary files /dev/null and b/database/clientsimg/AndrzejKowalski.png differ
diff --git a/database/clientsimg/DavidBowie.png b/database/clientsimg/DavidBowie.png
new file mode 100644
index 0000000..8b0bc68
Binary files /dev/null and b/database/clientsimg/DavidBowie.png differ
diff --git a/database/clientsimg/JonSnow.png b/database/clientsimg/JonSnow.png
new file mode 100644
index 0000000..61a0484
Binary files /dev/null and b/database/clientsimg/JonSnow.png differ
diff --git a/database/clientsimg/KamilStop.png b/database/clientsimg/KamilStop.png
new file mode 100644
index 0000000..8d15f1c
Binary files /dev/null and b/database/clientsimg/KamilStop.png differ
diff --git a/decisiontree.py b/decisiontree.py
index cbd96d4..8e5513f 100644
--- a/decisiontree.py
+++ b/decisiontree.py
@@ -64,13 +64,13 @@ dot_data = tree.export_graphviz(clf_en, out_file=None,
"Behaviour": random.choice(['Energetic', 'Stressed', 'Calm'])
} """
-def predict_client(client_data):
+def predict_client(client_data,glasses):
new_client = {
"Wrinkles": client_data.zmarszczki,
"Balding": client_data.lysienie,
"Beard": client_data.broda,
"Outfit": client_data.ubior,
- "Glasses": client_data.okulary,
+ "Glasses": 'Yes' if glasses == 1 else 'No',
"Tattoo": client_data.tatuaz,
"Hair": client_data.wlosy,
"Behaviour": client_data.zachowanie