From 1bcce19de215206ee254dca408b4a17736167cb3 Mon Sep 17 00:00:00 2001 From: Juundi Date: Fri, 27 May 2022 05:26:14 +0200 Subject: [PATCH] nn implementation --- snn/snn.py | 18 ++++++++++++++++++ src/board.py | 14 +++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 snn/snn.py diff --git a/snn/snn.py b/snn/snn.py new file mode 100644 index 0000000..190dbd5 --- /dev/null +++ b/snn/snn.py @@ -0,0 +1,18 @@ +from fastai.vision.all import * +import pathlib + +temp = pathlib.PosixPath +pathlib.PosixPath = pathlib.WindowsPath + +DATASET_PATH = Path('../dataset') + +learn = load_learner(DATASET_PATH/'export.pkl') +path = Path(DATASET_PATH/'glass/glass1.jpg') + +def getPredict(learner, path): + prediction = learner.predict(path) + predictionName = learner.predict(path)[0] + print(prediction, '\n\n','prediction:', predictionName, 'path:', path) + return prediction + +getPredict(learn, path) \ No newline at end of file diff --git a/src/board.py b/src/board.py index 14746a4..edc84e6 100644 --- a/src/board.py +++ b/src/board.py @@ -61,7 +61,7 @@ class Agent(Object): circleX = 52 + self.pos.x * square circleY = 12 + self.pos.y * square - truck = pygame.image.load("car.png").convert_alpha() # tu ścieżka do zdjęcia w tle + truck = pygame.image.load("../car.png").convert_alpha() # tu ścieżka do zdjęcia w tle truck = pygame.transform.scale(truck, (square, square)) screen.blit(truck, (circleX, circleY)) @@ -82,14 +82,14 @@ class House(Object): "paper": False, "glass": False, "plastic": False, - "bio": False + "others": False } def draw(self, square): x = 52 + self.pos.x * square y = 12 + self.pos.y * square - house = pygame.image.load("house.png").convert_alpha() # tu ścieżka do zdjęcia w tle + house = pygame.image.load("../house.png").convert_alpha() # tu ścieżka do zdjęcia w tle house = pygame.transform.scale(house, (square, square)) screen.blit(house, (x, y)) @@ -101,14 +101,14 @@ class Junkyard(Object): "paper": True, "glass": True, "plastic": True, - "bio": True + "others": True } def draw(self, square): x = 52 + self.pos.x * square y = 12 + self.pos.y * square - junkyard = pygame.image.load("junkyard.png").convert_alpha() # tu ścieżka do zdjęcia w tle + junkyard = pygame.image.load("../junkyard.png").convert_alpha() # tu ścieżka do zdjęcia w tle junkyard = pygame.transform.scale(junkyard, (square, square)) screen.blit(junkyard, (x, y)) @@ -121,7 +121,7 @@ class Hole(Object): x = 52 + self.pos.x * square y = 12 + self.pos.y * square - hole = pygame.image.load("hole.png").convert_alpha() # tu ścieżka do zdjęcia w tle + hole = pygame.image.load("../hole.png").convert_alpha() # tu ścieżka do zdjęcia w tle hole = pygame.transform.scale(hole, (square, square)) screen.blit(hole, (x, y)) @@ -154,7 +154,7 @@ def draw(square_num, objectArr): def kb_listen(objectArray, gridLength, path): agent = objectArray[0] - agent.move(gridLength, path) + #agent.move(gridLength, path) if __name__ == '__main__': pygame.init() # inicjalizacja modułów, na razie niepotrzebna