nn implementation
This commit is contained in:
parent
4e78dfdbab
commit
1bcce19de2
18
snn/snn.py
Normal file
18
snn/snn.py
Normal file
@ -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)
|
14
src/board.py
14
src/board.py
@ -61,7 +61,7 @@ class Agent(Object):
|
|||||||
circleX = 52 + self.pos.x * square
|
circleX = 52 + self.pos.x * square
|
||||||
circleY = 12 + self.pos.y * 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))
|
truck = pygame.transform.scale(truck, (square, square))
|
||||||
screen.blit(truck, (circleX, circleY))
|
screen.blit(truck, (circleX, circleY))
|
||||||
|
|
||||||
@ -82,14 +82,14 @@ class House(Object):
|
|||||||
"paper": False,
|
"paper": False,
|
||||||
"glass": False,
|
"glass": False,
|
||||||
"plastic": False,
|
"plastic": False,
|
||||||
"bio": False
|
"others": False
|
||||||
}
|
}
|
||||||
|
|
||||||
def draw(self, square):
|
def draw(self, square):
|
||||||
x = 52 + self.pos.x * square
|
x = 52 + self.pos.x * square
|
||||||
y = 12 + self.pos.y * 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))
|
house = pygame.transform.scale(house, (square, square))
|
||||||
screen.blit(house, (x, y))
|
screen.blit(house, (x, y))
|
||||||
|
|
||||||
@ -101,14 +101,14 @@ class Junkyard(Object):
|
|||||||
"paper": True,
|
"paper": True,
|
||||||
"glass": True,
|
"glass": True,
|
||||||
"plastic": True,
|
"plastic": True,
|
||||||
"bio": True
|
"others": True
|
||||||
}
|
}
|
||||||
|
|
||||||
def draw(self, square):
|
def draw(self, square):
|
||||||
x = 52 + self.pos.x * square
|
x = 52 + self.pos.x * square
|
||||||
y = 12 + self.pos.y * 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))
|
junkyard = pygame.transform.scale(junkyard, (square, square))
|
||||||
screen.blit(junkyard, (x, y))
|
screen.blit(junkyard, (x, y))
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class Hole(Object):
|
|||||||
x = 52 + self.pos.x * square
|
x = 52 + self.pos.x * square
|
||||||
y = 12 + self.pos.y * 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))
|
hole = pygame.transform.scale(hole, (square, square))
|
||||||
screen.blit(hole, (x, y))
|
screen.blit(hole, (x, y))
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ def draw(square_num, objectArr):
|
|||||||
|
|
||||||
def kb_listen(objectArray, gridLength, path):
|
def kb_listen(objectArray, gridLength, path):
|
||||||
agent = objectArray[0]
|
agent = objectArray[0]
|
||||||
agent.move(gridLength, path)
|
#agent.move(gridLength, path)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pygame.init() # inicjalizacja modułów, na razie niepotrzebna
|
pygame.init() # inicjalizacja modułów, na razie niepotrzebna
|
||||||
|
Loading…
Reference in New Issue
Block a user