refactor #26
14
Image.py
14
Image.py
@ -55,15 +55,25 @@ class Image:
|
||||
|
||||
def return_gasStation(self):
|
||||
return self.gasStation_image
|
||||
|
||||
|
||||
# losowanie zdjęcia z testowego datasetu bez powtórzeń
|
||||
imagePathList = []
|
||||
def getRandomImageFromDataBase():
|
||||
label = random.choice(neuralnetwork.labels)
|
||||
|
||||
folderPath = f"dataset/test/{label}"
|
||||
files = os.listdir(folderPath)
|
||||
random_image = random.choice(files)
|
||||
imgPath = os.path.join(folderPath, random_image)
|
||||
|
||||
while imgPath in imagePathList:
|
||||
label = random.choice(neuralnetwork.labels)
|
||||
folderPath = f"dataset/test/{label}"
|
||||
files = os.listdir(folderPath)
|
||||
random_image = random.choice(files)
|
||||
imgPath = os.path.join(folderPath, random_image)
|
||||
|
||||
imagePathList.append(imgPath)
|
||||
|
||||
image = pygame.image.load(imgPath)
|
||||
image=pygame.transform.scale(image,(dCon.CUBE_SIZE,dCon.CUBE_SIZE))
|
||||
return image, label, imgPath
|
||||
|
@ -198,7 +198,7 @@ class Tractor:
|
||||
for j in range(initPos[0], dCon.NUM_X):
|
||||
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")
|
||||
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])
|
||||
self.move_forward(pole, False)
|
||||
if i % 2 == 0 and i != dCon.NUM_Y - 1:
|
||||
self.turn_right()
|
||||
|
@ -9,8 +9,8 @@ from PIL import Image
|
||||
import random
|
||||
|
||||
imageSize = (128, 128)
|
||||
labels = ['beetroot', 'potato', 'carrot']
|
||||
labels.sort()
|
||||
labels = ['beetroot', 'carrot', 'potato'] # musi być w kolejności alfabetycznej
|
||||
fertilizer = {labels[0]: 'kompost', labels[1]: 'saletra amonowa', labels[2]: 'superfosfat'}
|
||||
|
||||
torch.manual_seed(42)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user