Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7f5b8c5d1b
@ -5,7 +5,7 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Python 3.10" jdkType="Python SDK" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (ai-project)" project-jdk-type="Python SDK" />
|
||||
</project>
|
10
main.py
10
main.py
@ -1,13 +1,13 @@
|
||||
import pygame
|
||||
|
||||
from src.utils.xgb_model import Model
|
||||
import warnings
|
||||
warnings.simplefilter(action='ignore', category=FutureWarning)
|
||||
from src.utils.xgb_model import XgbModel
|
||||
from src.world import World
|
||||
from src.tractor import Tractor
|
||||
from src.settings import Settings
|
||||
from src.utils.bfs import BFSSearcher
|
||||
from src.constants import Constants as C
|
||||
from utils.display_info import display_tile_info
|
||||
import warnings
|
||||
|
||||
|
||||
def main():
|
||||
@ -15,8 +15,8 @@ def main():
|
||||
pygame.init()
|
||||
|
||||
settings = Settings()
|
||||
model = Model()
|
||||
world = World(settings, model)
|
||||
xgb_model = XgbModel()
|
||||
world = World(settings, xgb_model)
|
||||
tractor = Tractor("Spalinowy", "Nawóz 1", settings, 0 * settings.tile_size, 0 * settings.tile_size, C.RIGHT)
|
||||
plants_to_water = [tile for tile in world.tiles if tile.to_water == 1]
|
||||
clock = pygame.time.Clock() # FPS purpose
|
||||
|
@ -12,6 +12,7 @@ class Tile(Sprite):
|
||||
self.col_id = col_id
|
||||
self.position = (row_id, col_id)
|
||||
self.image = image
|
||||
self.cnn_image = image
|
||||
self.rect = rect
|
||||
self.cost = cost
|
||||
|
||||
@ -24,6 +25,8 @@ class Tile(Sprite):
|
||||
self.rodzaj_nawozu = rodzaj_nawozu
|
||||
self.to_water = to_water
|
||||
|
||||
self.predicted_plant = None
|
||||
|
||||
def __repr__(self):
|
||||
return "(type: %s, position: (%s, %s), cost: %s, rodzaj_rośliny: %s, to_water: %s)" % \
|
||||
(self.type, self.row_id, self.col_id, self.cost, self.rodzaj_rosliny, self.to_water)
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,7 @@ def display_tile_info(world_map: World, screen: pygame.Surface):
|
||||
|
||||
# wyświetlenie obrazu
|
||||
# 9 - y bo gdzieś w kodzie jest odwrócona oś y
|
||||
screen.blit(pygame.transform.scale(tile_info.image, (140, 140)), (735, 35))
|
||||
screen.blit(pygame.transform.scale(tile_info.cnn_image, (140, 140)), (735, 35))
|
||||
|
||||
# init fonta
|
||||
font = pygame.font.Font('assets/images/display_info/Minecraft.ttf', 16)
|
||||
@ -33,9 +33,9 @@ def display_tile_info(world_map: World, screen: pygame.Surface):
|
||||
text_render = font.render(str(tile_info.get_position()), True, WHITE)
|
||||
screen.blit(text_render, (731, 332))
|
||||
|
||||
# koszt tile'a
|
||||
# koszt tile'a - tu bd predicted
|
||||
pygame.draw.rect(screen, (139, 139, 139), pygame.Rect(724, 401, 162, 23))
|
||||
text_render = font.render(str(tile_info.get_cost()), True, WHITE)
|
||||
text_render = font.render(str(tile_info.predicted_plant), True, WHITE)
|
||||
screen.blit(text_render, (731, 406))
|
||||
|
||||
# typ rośliny
|
||||
|
10
src/utils/imageDownloader.py
Normal file
10
src/utils/imageDownloader.py
Normal file
@ -0,0 +1,10 @@
|
||||
from bing_image_downloader import downloader
|
||||
|
||||
# downloader.download('cactus', limit=1000, output_dir='images',
|
||||
# adult_filter_off=True, force_replace=False, timeout=60, verbose=True)
|
||||
|
||||
# downloader.download('potato', limit=1000, output_dir='images',
|
||||
# adult_filter_off=True, force_replace=False, timeout=60, verbose=True)
|
||||
|
||||
downloader.download('wheat', limit=1000, output_dir='images',
|
||||
adult_filter_off=True, force_replace=False, timeout=60, verbose=True)
|
@ -3,13 +3,13 @@ import pickle
|
||||
import xgboost
|
||||
|
||||
|
||||
class Model:
|
||||
""" Class to represent trained XGBoost model that predicts data on our board """
|
||||
class XgbModel:
|
||||
""" Class to represent trained XGBoost xgb_model that predicts data on our board """
|
||||
|
||||
def __init__(self):
|
||||
self.input_path = 'assets/data/test.csv'
|
||||
self.df = pd.read_csv(self.input_path)
|
||||
self.model = pickle.load(open('assets/model/xgboost_model.pkl', 'rb'))
|
||||
self.model = pickle.load(open('assets/xgb_model/xgboost_model.pkl', 'rb'))
|
||||
self.X_test = None
|
||||
self.y_test = None
|
||||
self.parse_input()
|
||||
|
@ -37,7 +37,7 @@ class World:
|
||||
col_count = 0
|
||||
for tile in row:
|
||||
if tile == 1:
|
||||
type = 'dirt' # type dirt mówimy nam ogólnie, ze jest to pole uprawne, szczegóły rośliny potem
|
||||
type = 'farm' # type farm mówimy nam ogólnie, ze jest to pole uprawne, szczegóły rośliny potem
|
||||
cost = 0
|
||||
stan_nawodnienia = self.model.df.iloc[df_idx]['stan_nawodnienia']
|
||||
rodzaj_gleby = self.model.df.iloc[df_idx]['rodzaj_gleby']
|
||||
|
Loading…
Reference in New Issue
Block a user