Merge branch 'main' of https://repos.hackathon.bz.it/2025-summer/team-2
|
@ -13,21 +13,7 @@ class MyApp extends StatelessWidget {
|
|||
return MaterialApp(
|
||||
title: 'SleepySound',
|
||||
theme: ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// TRY THIS: Try running your application with "flutter run". You'll see
|
||||
// the application has a purple toolbar. Then, without quitting the app,
|
||||
// try changing the seedColor in the colorScheme below to Colors.green
|
||||
// and then invoke "hot reload" (save your changes or press the "hot
|
||||
// reload" button in a Flutter-supported IDE, or press "r" if you used
|
||||
// the command line to start the app).
|
||||
//
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// state is not lost during the reload. To reset the state, use hot
|
||||
// restart instead.
|
||||
//
|
||||
// This works for code too, not just values: Most code changes can be
|
||||
// tested with just a hot reload.
|
||||
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||
),
|
||||
home: const MyHomePage(title: 'Now Playing'),
|
||||
|
@ -38,15 +24,6 @@ class MyApp extends StatelessWidget {
|
|||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({super.key, required this.title});
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
|
|
BIN
__pycache__/script.cpython-311.pyc
Normal file
BIN
basilico.jpg
Normal file
After Width: | Height: | Size: 1.4 MiB |
42
forDashboardIntegration.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
from datetime import datetime
|
||||
from script import PlantPredictor
|
||||
|
||||
def dashboard_plant_prediction(image_path, start_date, end_date, additional_notes=""):
|
||||
"""
|
||||
Simple function for dashboard integration
|
||||
"""
|
||||
try:
|
||||
# Calculate days
|
||||
start_dt = datetime.strptime(start_date, "%Y-%m-%d")
|
||||
end_dt = datetime.strptime(end_date, "%Y-%m-%d")
|
||||
days = (end_dt - start_dt).days
|
||||
|
||||
if days <= 0:
|
||||
return {"success": False, "error": "Invalid date range"}
|
||||
|
||||
# Create predictor and run
|
||||
predictor = PlantPredictor()
|
||||
result = predictor.dashboard_plant_prediction(image_path, days, additional_notes)
|
||||
|
||||
if result:
|
||||
return {"success": True, "result": result}
|
||||
else:
|
||||
return {"success": False, "error": "No result"}
|
||||
|
||||
except Exception as e:
|
||||
return {"success": False, "error": str(e)}
|
||||
|
||||
|
||||
# Test
|
||||
if __name__ == "__main__":
|
||||
result = dashboard_plant_prediction(
|
||||
"./basilico.jpg",
|
||||
"2024-08-01",
|
||||
"2024-08-08",
|
||||
"Test plant"
|
||||
)
|
||||
|
||||
if result["success"]:
|
||||
print(" SUCCESS!")
|
||||
else:
|
||||
print(f" ERROR: {result['error']}")
|
60
script.py
Normal file
|
@ -0,0 +1,60 @@
|
|||
from datetime import datetime
|
||||
import sys
|
||||
import os
|
||||
|
||||
class PlantPredictor:
|
||||
def dashboard_plant_prediction(
|
||||
image_path: str,
|
||||
start_date: str,
|
||||
end_date: str,
|
||||
additional_notes: str = ""
|
||||
) -> dict:
|
||||
try:
|
||||
# Calcola giorni
|
||||
start_dt = datetime.strptime(start_date, "%Y-%m-%d")
|
||||
end_dt = datetime.strptime(end_date, "%Y-%m-%d")
|
||||
days = (end_dt - start_dt).days
|
||||
if days <= 0:
|
||||
return {"success": False, "error": "End date must be after start date", "days": days}
|
||||
|
||||
# Log
|
||||
print(f"Dashboard prediction request: {start_date} to {end_date} ({days} days) image={image_path}")
|
||||
if additional_notes:
|
||||
print(f"Notes: {additional_notes}")
|
||||
|
||||
# Inizializza il predictor e chiama il metodo
|
||||
predictor = PlantPredictor()
|
||||
result = predictor.predict_plant_growth(image_path, days, additional_notes)
|
||||
|
||||
# Unwrap risultato tuple
|
||||
if isinstance(result, tuple) and len(result) == 5:
|
||||
_img, conditions, weather_df, plant_type, plant_health = result
|
||||
return {
|
||||
"success": True,
|
||||
"plant_analysis": {"plant_type": plant_type, "plant_health": plant_health},
|
||||
"weather_conditions": conditions,
|
||||
"weather_data_shape": weather_df.shape,
|
||||
"parameters_used": {"start_date": start_date, "end_date": end_date, "days": days, "notes": additional_notes, "image": image_path},
|
||||
"prediction_summary": {
|
||||
"temperature_range": f"{conditions['avg_temp_min']}–{conditions['avg_temp_max']}°C",
|
||||
"total_rain": f"{conditions['total_rain']}mm",
|
||||
"sunshine_hours": f"{conditions['total_sunshine_hours']}h"
|
||||
}
|
||||
}
|
||||
else:
|
||||
return {"success": False, "error": "Invalid result from PlantPredictor", "result": result}
|
||||
|
||||
except ValueError as e:
|
||||
return {"success": False, "error": f"Date format error: {e}"}
|
||||
except Exception as e:
|
||||
return {"success": False, "error": f"Unexpected error: {e}"}
|
||||
|
||||
# Esempio di test
|
||||
if __name__ == '__main__':
|
||||
res = dashboard_plant_prediction(
|
||||
image_path='./basilico.jpg',
|
||||
start_date='2024-08-01',
|
||||
end_date='2024-08-08',
|
||||
additional_notes='Indoor day 3'
|
||||
)
|
||||
print(res)
|
BIN
test2_with_training_tuned_with_basil_and_tomaetos/.cache.sqlite
Normal file
|
@ -0,0 +1,7 @@
|
|||
## this app requires:
|
||||
- python >= 3.11.0
|
||||
|
||||
### How to run:
|
||||
- cd inside the root of the project
|
||||
- install all necessary dependencies from the txt by doing : "pip install -r requirements.txt"
|
||||
- run by doing python script.py
|
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 81 KiB |
|
@ -0,0 +1,17 @@
|
|||
openmeteo-requests
|
||||
pandas
|
||||
torch
|
||||
diffusers
|
||||
transformers
|
||||
pillow
|
||||
requests-cache
|
||||
retry-requests
|
||||
numpy
|
||||
accelerate
|
||||
hf_xet
|
||||
geocoder
|
||||
torchvision
|
||||
requests
|
||||
retry-requests
|
||||
scikit-learn
|
||||
kaggle
|
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 165 KiB |
After Width: | Height: | Size: 132 KiB |
After Width: | Height: | Size: 177 KiB |
After Width: | Height: | Size: 524 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 213 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 238 KiB |
After Width: | Height: | Size: 208 KiB |
After Width: | Height: | Size: 582 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 1.4 MiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 128 KiB |
After Width: | Height: | Size: 930 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 151 KiB |
After Width: | Height: | Size: 223 KiB |
After Width: | Height: | Size: 145 KiB |
After Width: | Height: | Size: 704 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 123 KiB |
After Width: | Height: | Size: 149 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 180 KiB |
After Width: | Height: | Size: 702 KiB |
After Width: | Height: | Size: 115 KiB |
After Width: | Height: | Size: 200 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 224 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 707 KiB |
After Width: | Height: | Size: 375 KiB |
After Width: | Height: | Size: 127 KiB |
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 725 KiB |
After Width: | Height: | Size: 98 KiB |
After Width: | Height: | Size: 295 KiB |
After Width: | Height: | Size: 544 KiB |
After Width: | Height: | Size: 125 KiB |
After Width: | Height: | Size: 72 KiB |
After Width: | Height: | Size: 403 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 158 KiB |
After Width: | Height: | Size: 262 KiB |
After Width: | Height: | Size: 192 KiB |
After Width: | Height: | Size: 220 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 188 KiB |
After Width: | Height: | Size: 161 KiB |
After Width: | Height: | Size: 175 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 295 KiB |
After Width: | Height: | Size: 301 KiB |
After Width: | Height: | Size: 201 KiB |
After Width: | Height: | Size: 583 KiB |
After Width: | Height: | Size: 298 KiB |
After Width: | Height: | Size: 172 KiB |
After Width: | Height: | Size: 122 KiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 340 KiB |
After Width: | Height: | Size: 113 KiB |
After Width: | Height: | Size: 239 KiB |
After Width: | Height: | Size: 200 KiB |
After Width: | Height: | Size: 770 KiB |
After Width: | Height: | Size: 82 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 1.7 MiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 186 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 137 KiB |
After Width: | Height: | Size: 250 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 200 KiB |
After Width: | Height: | Size: 67 KiB |
After Width: | Height: | Size: 300 KiB |
After Width: | Height: | Size: 749 KiB |
After Width: | Height: | Size: 590 KiB |
After Width: | Height: | Size: 748 KiB |
After Width: | Height: | Size: 468 KiB |
After Width: | Height: | Size: 159 KiB |
After Width: | Height: | Size: 186 KiB |
After Width: | Height: | Size: 289 KiB |