dodano zastosowanie sieci neuronowej w main
This commit is contained in:
parent
9667655a2a
commit
35d7a6ab6e
@ -63,14 +63,34 @@ def main():
|
|||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
run = False
|
run = False
|
||||||
|
|
||||||
#small test of work_on_field method:
|
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tile1 = tiles[0]
|
|
||||||
|
# movement based on route-planning (test):
|
||||||
|
|
||||||
|
tractor.draw_tractor(WIN)
|
||||||
|
time.sleep(1)
|
||||||
|
if moves != False:
|
||||||
|
do_actions(tractor, WIN, moves)
|
||||||
|
|
||||||
|
|
||||||
|
#guessing the image under the tile:
|
||||||
|
goalTile = tiles[tile_index]
|
||||||
|
goalTile.display_photo()
|
||||||
|
image_path = goalTile.photo
|
||||||
|
image_tensor = load_image(image_path)
|
||||||
|
prediction = guess_image(load_model(), image_tensor)
|
||||||
|
print(f"The predicted image is: {prediction}")
|
||||||
|
|
||||||
|
|
||||||
p1 = Plant('wheat', 'cereal', random.randint(1,100), random.randint(1,100), random.randint(1,100))
|
p1 = Plant('wheat', 'cereal', random.randint(1,100), random.randint(1,100), random.randint(1,100))
|
||||||
|
goalTile.plant = p1
|
||||||
d1 = Dirt(random.randint(1, 100), random.randint(1,100))
|
d1 = Dirt(random.randint(1, 100), random.randint(1,100))
|
||||||
d1.pests_and_weeds()
|
d1.pests_and_weeds()
|
||||||
tile1.ground=d1
|
goalTile.ground=d1
|
||||||
|
#getting the name and type of the recognized plant:
|
||||||
|
p1.update_name(prediction)
|
||||||
|
|
||||||
|
#decission tree test:
|
||||||
if d1.pest:
|
if d1.pest:
|
||||||
pe = 1
|
pe = 1
|
||||||
else:
|
else:
|
||||||
@ -117,25 +137,12 @@ def main():
|
|||||||
|
|
||||||
model = joblib.load('model.pkl')
|
model = joblib.load('model.pkl')
|
||||||
nowe_dane = pd.read_csv('model_data.csv')
|
nowe_dane = pd.read_csv('model_data.csv')
|
||||||
|
|
||||||
predykcje = model.predict(nowe_dane)
|
predykcje = model.predict(nowe_dane)
|
||||||
|
|
||||||
# movement based on route-planning (test):
|
|
||||||
|
|
||||||
tractor.draw_tractor(WIN)
|
|
||||||
time.sleep(1)
|
|
||||||
if moves != False:
|
|
||||||
do_actions(tractor, WIN, moves)
|
|
||||||
print(predykcje)
|
print(predykcje)
|
||||||
if predykcje == 'work':
|
|
||||||
tractor.work_on_field(tile1, d1, p1)
|
|
||||||
|
|
||||||
#guessing the image under the tile:
|
#work on field:
|
||||||
tiles[tile_index].display_photo()
|
if predykcje == 'work':
|
||||||
image_path = tiles[tile_index].photo
|
tractor.work_on_field(goalTile, d1, p1)
|
||||||
image_tensor = load_image(image_path)
|
|
||||||
prediction = guess_image(load_model(), image_tensor)
|
|
||||||
print(f"The predicted image is: {prediction}")
|
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
print("\n")
|
print("\n")
|
||||||
|
|
||||||
|
@ -19,7 +19,23 @@ class Plant:
|
|||||||
else:
|
else:
|
||||||
print("Unable to grow due to bad condition of the ground")
|
print("Unable to grow due to bad condition of the ground")
|
||||||
|
|
||||||
# more properties
|
def update_name(self, predicted_class):
|
||||||
|
if predicted_class == "Apple":
|
||||||
|
self.name = "Apple"
|
||||||
|
self.plant_type = "fruit"
|
||||||
|
|
||||||
|
elif predicted_class == "Strawberry":
|
||||||
|
self.name = "Strawberry"
|
||||||
|
self.plant_type = "fruit"
|
||||||
|
|
||||||
# add init, getters,setters
|
elif predicted_class == "Cucumber":
|
||||||
|
self.name = "Cucumber"
|
||||||
|
self.plant_type = "vegetable"
|
||||||
|
|
||||||
|
elif predicted_class == "Cauliflower":
|
||||||
|
self.name = "Cauliflower"
|
||||||
|
self.plant_type = "vegetable"
|
||||||
|
|
||||||
|
elif predicted_class == "Wheat":
|
||||||
|
self.name = "Wheat"
|
||||||
|
self.plant_type = "cereal"
|
Loading…
Reference in New Issue
Block a user