Downloads · 30 days
0
mahmoudelbahy33/irrigation
irrigation is a machine learning model from mahmoudelbahy33. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
0
Access
Public
Updated Dec 12, 2025
Repo size
12.3 MB
Likes
0
Public
Click a slice to open those files.
.pkl11.8 MB · 87%
From the Hugging Face model README
نظام ذكي يستخدم تعلم الآلة للتنبؤ باحتياجات الري لملاعب كرة القدم في الرياض بناءً على بيانات الطقس.
An intelligent system using machine learning to predict irrigation needs for football stadiums in Riyadh based on weather data.
</div># Clone the repository
git clone https://github.com/M-craspo/riyadh-pitch-ai-irrigation.git
# الدخول إلى مجلد المشروع
cd riyadh-pitch-ai-irrigation
تأكد من تثبيت:
# الدخول إلى مجلد Backend
cd irrigation_model
# تثبيت المكتبات المطلوبة
pip install -r requirements.txt
# أو استخدم pip3 إذا كان لديك Python 2 و 3
pip3 install -r requirements.txt
# العودة إلى المجلد الرئيسي
cd ..
المكتبات التي سيتم تثبيتها:
# الدخول إلى مجلد Frontend
cd frontend
# تثبيت المكتبات المطلوبة
npm install
# العودة إلى المجلد الرئيسي
cd ..
المكتبات التي سيتم تثبيتها:
على macOS/Linux:
# إعطاء صلاحية التنفيذ
chmod +x start.sh
# تشغيل السكريبت
./start.sh
على Windows:
# تشغيل Backend
start cmd /k "cd irrigation_model && python api.py"
# تشغيل Frontend (في نافذة جديدة)
start cmd /k "cd frontend && npm run dev"
1. تشغيل Backend (نافذة Terminal أولى):
# الدخول إلى مجلد Backend
cd irrigation_model
# تشغيل API Server
python3 api.py
# أو استخدم python بدلاً من python3
python api.py
✅ ستظهر رسالة:
* Running on http://127.0.0.1:5001
* Model loaded successfully!
* Ready to serve predictions
الخادم سيعمل على: http://localhost:5001
2. تشغيل Frontend (نافذة Terminal ثانية - جديدة):
# افتح نافذة Terminal جديدة
# الدخول إلى مجلد Frontend
cd frontend
# تشغيل Development Server
npm run dev
✅ ستظهر رسالة:
VITE v5.4.19 ready in 170 ms
➜ Local: http://localhost:8080/
➜ Network: http://192.168.x.x:8080/
الموقع سيعمل على: http://localhost:8080
في كل بطاقة ملعب، ستجد قسم "جدول الري المستقبلي":
خيار 1: عدة أيام
خيار 2: يوم محدد
لإيقاف الخوادم:
Ctrl + C في كل نافذة Terminalالخطأ: ModuleNotFoundError: No module named 'flask'
الحل:
cd irrigation_model
pip install -r requirements.txt
الخطأ: Port 5001 is already in use
الحل:
# على macOS/Linux
lsof -ti:5001 | xargs kill -9
# على Windows
netstat -ano | findstr :5001
taskkill /PID <PID_NUMBER> /F
الخطأ: python: command not found
الحل:
python3 بدلاً من pythonالخطأ: npm: command not found
الحل:
الخطأ: Port 8080 is already in use
الحل:
# على macOS/Linux
lsof -ti:8080 | xargs kill -9
# على Windows
netstat -ano | findstr :8080
taskkill /PID <PID_NUMBER> /F
أو غيّر المنفذ في frontend/vite.config.ts:
server: {
port: 3000, // غيّر إلى منفذ آخر
}
الخطأ: Failed to fetch في المتصفح
الحل:
http://localhost:5001http://localhost:5001/api/health في المتصفح{"status": "healthy", "model_loaded": true}الحل:
الحل:
إذا واجهت أي مشكلة:
python --version)node --version)POST /api/predict
Content-Type: application/json
{
"T2M_MIN": 20,
"T2M_MAX": 39,
"RH2M": 20,
"WS2M": 2.5
}
POST /api/schedule
Content-Type: application/json
{
"days": 7,
"current_weather": {
"T2M_MIN": 20,
"T2M_MAX": 39,
"RH2M": 20,
"WS2M": 2.5
}
}
POST /api/predict-date
Content-Type: application/json
{
"date": "2025-11-30",
"current_weather": {
"T2M_MIN": 20,
"T2M_MAX": 39,
"RH2M": 20,
"WS2M": 2.5
}
}
GET /api/health
GET /api/stats
Response:
{
"success": true,
"stats": {
"model_type": "RandomForestRegressor",
"accuracy": 99.3,
"training_samples": 4689,
"features": ["T2M_MIN", "T2M_MAX", "RH2M", "WS2M", "PRECTOTCORR", "ALLSKY_SFC_SW_DWN"]
}
}
curl -X POST http://localhost:5001/api/predict \
-H "Content-Type: application/json" \
-d '{
"T2M_MIN": 25,
"T2M_MAX": 42,
"RH2M": 18,
"WS2M": 3.2
}'
النتيجة:
{
"success": true,
"irrigation_m3": 71.58,
"irrigation_liters": 71580,
"sessions": [
{"time": "05:00", "water_m3": 35.79, "duration_minutes": 30},
{"time": "19:00", "water_m3": 35.79, "duration_minutes": 30}
]
}
curl -X POST http://localhost:5001/api/schedule \
-H "Content-Type: application/json" \
-d '{
"days": 7,
"current_weather": {
"T2M_MIN": 25,
"T2M_MAX": 42,
"RH2M": 18,
"WS2M": 3.2
}
}'
curl -X POST http://localhost:5001/api/predict-date \
-H "Content-Type: application/json" \
-d '{
"date": "2025-12-01",
"current_weather": {
"T2M_MIN": 20,
"T2M_MAX": 35,
"RH2M": 30,
"WS2M": 2.5
}
}'
// الحصول على تنبؤ
async function getPrediction() {
const response = await fetch('http://localhost:5001/api/predict', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
T2M_MIN: 25,
T2M_MAX: 42,
RH2M: 18,
WS2M: 3.2
})
});
const data = await response.json();
console.log('احتياجات المياه:', data.irrigation_liters, 'لتر');
console.log('عدد الجلسات:', data.sessions.length);
}
getPrediction();
import requests
import json
# الحصول على جدول 14 يوم
url = 'http://localhost:5001/api/schedule'
data = {
'days': 14,
'current_weather': {
'T2M_MIN': 25,
'T2M_MAX': 42,
'RH2M': 18,
'WS2M': 3.2
}
}
response = requests.post(url, json=data)
result = response.json()
if result['success']:
for day in result['schedule']:
print(f"التاريخ: {day['date']}")
print(f"المياه: {day['irrigation_liters']:,} لتر")
print(f"الجلسات: {len(day['sessions'])}")
print("---")
T2M_MIN: درجة الحرارة الصغرى (°C)T2M_MAX: درجة الحرارة العظمى (°C)RH2M: الرطوبة النسبية (%)WS2M: سرعة الرياح (m/s)PRECTOTCORR: الأمطار (mm)ALLSKY_SFC_SW_DWN: الإشعاع الشمسي (MJ/m²/day)riyadh-pitch-ai-irrigation/
├── irrigation_model/ # Backend (Python/Flask)
│ ├── api.py # REST API
│ ├── irrigation_predictor.py # ML Model
│ ├── data_preprocessing.py # Data Processing
│ ├── train_model.py # Model Training
│ ├── trained_model.pkl # Trained Model
│ └── requirements.txt # Python Dependencies
│
├── frontend/ # Frontend (React/TypeScript)
│ ├── src/
│ │ ├── components/ # React Components
│ │ ├── services/ # API Services
│ │ └── pages/ # Pages
│ └── package.json # Node Dependencies
│
├── POWER_Point_Daily_*.xlsx # NASA Weather Data
├── Riyadh_sprinkler_*.xlsx # Irrigation Data
├── start.sh # Startup Script
└── README.md # This File
الموقع يعرض:
ج: نعم! بعد تحميل المشروع وتثبيت المكتبات، يعمل النظام بالكامل على جهازك المحلي بدون الحاجة للإنترنت.
ج: النظام يستخدم:
ج: النموذج حقق دقة 99.3% على بيانات الاختبار، مع:
ج: النظام يحدد عدد الجلسات بناءً على الظروف الجوية:
ج: نعم! يمكنك تعديل ملف frontend/src/components/sections/EnhancedDashboardSection.tsx وإضافة ملاعب جديدة بنفس الصيغة.
ج: نعم! في ملف irrigation_model/irrigation_predictor.py، غيّر قيمة:
self.field_area_m2 = 7140 # غيّر هذا الرقم
ج: يمكنك:
POWER_Point_Daily_*.xlsxpython irrigation_model/train_model.pyج: حالياً النظام بالعربية فقط. لإضافة لغات أخرى، يمكنك:
frontend/src/locales/i18next للترجمةج: يمكنك استخدام:
ج: نعم! غيّر معامل المحصول (Kc) في irrigation_predictor.py:
self.kc = 0.85 # للعشب
# self.kc = 1.15 # للطماطم
# self.kc = 0.60 # للقمح
نرحب بالمساهمات! إذا كنت تريد المساهمة:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)| المقياس | القيمة |
|---|---|
| 🎯 دقة النموذج | 99.3% |
| 📅 فترة البيانات | 12+ سنة |
| 📈 عدد السجلات | 4,689 يوم |
| 🏟️ عدد الملاعب | 6 ملاعب |
| 💧 متوسط الري اليومي | ~68 m³ |
| ⏰ جلسات الري | 1-3 جلسات/يوم |
| 🌡️ نطاق الحرارة | 10-50°C |
| 💦 نطاق الرطوبة | 5-70% |
┌─────────────────────────────────────────────────────────┐
│ 🌱 نظام الري الذكي لملاعب كرة القدم في الرياض │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ ملعب الملك فهد الدولي ✅ مثالي │ │
│ ├──────────────────────────────────────────────────┤ │
│ │ 🌡️ الحرارة: 39°C 💧 الرطوبة: 20% │ │
│ │ │ │
│ │ 💧 احتياجات المياه │ │
│ │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ │ │
│ │ إجمالي المياه: 68.5 m³ (68,550 لتر) │ │
│ │ │ │
│ │ ⏰ جلسات الري (2 جلسات) │ │
│ │ ┌────────────────────────────────────────────┐ │ │
│ │ │ 🕔 05:00 | 💧 34.3 m³ | ⏱️ 30 دقيقة │ │ │
│ │ │ 🕖 19:00 | 💧 34.3 m³ | ⏱️ 30 دقيقة │ │ │
│ │ └────────────────────────────────────────────┘ │ │
│ │ │ │
│ │ 📅 جدول الري المستقبلي │ │
│ │ [عدة أيام] [يوم محدد] │ │
│ │ اختر: [3] [7] [14] [30] يوم [عرض الجدول] │ │
│ └──────────────────────────────────────────────────┘ │
│ │
│ [5 ملاعب أخرى...] │
└─────────────────────────────────────────────────────────┘