neural_network #25
4
App.py
4
App.py
@ -21,7 +21,7 @@ if bfs3_flag or Astar or Astar2:
|
||||
Pole.stoneFlag = True
|
||||
TreeFlag=False
|
||||
nnFlag=True
|
||||
newModel=True
|
||||
newModel=False
|
||||
|
||||
pygame.init()
|
||||
show_console=True
|
||||
@ -124,7 +124,7 @@ def init_demo(): #Demo purpose
|
||||
if (newModel):
|
||||
print_to_console("uczenie sieci neuronowej")
|
||||
model = neuralnetwork.trainNewModel()
|
||||
neuralnetwork.saveModel(model, 'model2.pth')
|
||||
neuralnetwork.saveModel(model, 'model.pth')
|
||||
print_to_console("sieć nuronowa nauczona")
|
||||
print('model został wygenerowany')
|
||||
else:
|
||||
|
@ -202,7 +202,12 @@ class Tractor:
|
||||
quit()
|
||||
if self.slot.imagePath != None:
|
||||
predictedLabel = nn.predictLabel(self.slot.imagePath, model)
|
||||
print(str("Coords: ({:02d}, {:02d})").format(self.slot.x_axis, self.slot.y_axis), "real:", self.slot.label, "predicted:", predictedLabel, "correct" if (self.slot.label == predictedLabel) else "incorrect", 'nawożę za pomocą:', nn.fertilizer[predictedLabel])
|
||||
|
||||
# print(str("Coords: ({:02d}, {:02d})").format(self.slot.x_axis, self.slot.y_axis), "real:", self.slot.label, "predicted:", predictedLabel, "correct" if (self.slot.label == predictedLabel) else "incorrect", 'nawożę za pomocą:', nn.fertilizer[predictedLabel])
|
||||
if str(self.slot.label) != str(predictedLabel):
|
||||
print(str("Coords: ({:02d}, {:02d})").format(self.slot.x_axis, self.slot.y_axis))
|
||||
print("real: ", str(self.slot.label), "\tpredicted: ", str(predictedLabel), "\n")
|
||||
|
||||
if self.slot.label != predictedLabel:
|
||||
self.slot.mark_visited()
|
||||
count += 1
|
||||
|
@ -15,6 +15,8 @@ fertilizer = {labels[0]: 'kompost', labels[1]: 'saletra amonowa', labels[2]: 'su
|
||||
torch.manual_seed(42)
|
||||
|
||||
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
||||
# device = torch.device("mps") if torch.backends.mps.is_available() else torch.device('cpu')
|
||||
# print(device)
|
||||
|
||||
def getTransformation():
|
||||
transform=transforms.Compose([
|
||||
|
Loading…
Reference in New Issue
Block a user