twist-turn commited on
Commit
1c796e1
·
verified ·
1 Parent(s): 46d6b82

Upload 22 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ static/generated/crop_sim_1ea1f560731b4c84b365fe0cbfb5a411.png filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set working directory
4
+ WORKDIR /app
5
+
6
+ # Install system dependencies
7
+ RUN apt-get update && apt-get install -y \
8
+ gcc \
9
+ g++ \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy requirements first for better caching
13
+ COPY requirements.txt .
14
+
15
+ # Install Python dependencies
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # Copy application files
19
+ COPY . .
20
+
21
+ # Create necessary directories
22
+ RUN mkdir -p data cache static/uploads static/generated templates static/css static/js models
23
+
24
+ # Set environment variables
25
+ ENV FLASK_APP=app.py
26
+ ENV PYTHONUNBUFFERED=1
27
+ ENV PORT=7860
28
+
29
+ # Expose the port that Hugging Face Spaces expects
30
+ EXPOSE 7860
31
+
32
+ # Run the application
33
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -1,11 +1,124 @@
1
  ---
2
- title: Third
3
- emoji: 🔥
4
- colorFrom: gray
5
- colorTo: purple
6
  sdk: docker
7
  pinned: false
8
  license: mit
 
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Future Crop Simulator
3
+ emoji: 🌾
4
+ colorFrom: green
5
+ colorTo: blue
6
  sdk: docker
7
  pinned: false
8
  license: mit
9
+ app_port: 7860
10
  ---
11
 
12
+ # Future Crop Simulator 🌾
13
+
14
+ An advanced agricultural simulation platform that combines vegetation indices, weather forecasts, and soil data to generate future crop growth predictions and optimize crop rotation plans.
15
+
16
+ ## Features
17
+
18
+ ### 🌱 Core Capabilities
19
+ - **Multi-season crop growth simulations** with NDVI/EVI time series analysis
20
+ - **Weather-based forecasting** with scenario modeling (wet year, dry year, heatwave, low inputs)
21
+ - **Crop rotation optimization** using RL-style algorithms
22
+ - **Growth stage predictions** along detailed timelines
23
+ - **Soil and terrain analysis** with suitability scoring
24
+ - **Multi-panel visualization** of historical and forecasted data
25
+
26
+ ### 📊 Simulation Scenarios
27
+ - **Baseline**: Standard growing conditions
28
+ - **Wet Year**: Increased rainfall scenarios
29
+ - **Dry Year**: Drought conditions
30
+ - **Heatwave**: Extreme temperature events
31
+ - **Low Inputs**: Reduced fertilizer/resource scenarios
32
+
33
+ ### 🎯 What-If Analysis
34
+ Run comparative simulations to understand:
35
+ - Yield potential under different climate scenarios
36
+ - Crop stress risk factors
37
+ - Optimal rotation sequences for soil health
38
+ - Best crop selections based on local conditions
39
+
40
+ ## How It Works
41
+
42
+ ### Data Pipeline
43
+ 1. **Historical Data**: NDVI/EVI vegetation indices from satellite imagery (synthetic stubs for demo)
44
+ 2. **Weather Forecasts**: 30-day forward-looking temperature and rainfall data
45
+ 3. **Soil & Terrain**: Elevation, slope, texture, organic matter, and drainage profiles
46
+ 4. **Rotation Planning**: User-defined or optimized multi-season crop sequences
47
+
48
+ ### Model Architecture
49
+ - **Temporal Forecaster**: Growth trajectory predictions based on historical patterns
50
+ - **RL Optimizer**: MuZero-style rotation planning with simulated rollouts
51
+ - **Visualization Engine**: Multi-panel matplotlib-based imagery generation
52
+ - **Metrics Engine**: Yield index, stress risk, soil scoring, and health indicators
53
+
54
+ ## Usage
55
+
56
+ 1. **Select your region** from available field IDs
57
+ 2. **Choose a primary crop** (Maize, Wheat, Rice, Soybean, Cotton)
58
+ 3. **Set simulation parameters**: start date and number of seasons
59
+ 4. **Pick a scenario** to model different climate conditions
60
+ 5. **Define crop rotation** (inline text or upload CSV)
61
+ 6. **Run simulation** to generate visualizations and recommendations
62
+
63
+ ## Architecture
64
+
65
+ ### Backend Components
66
+ - `data_loader.py`: Data ingestion and preprocessing
67
+ - `temporal_forecaster.py`: Growth prediction models
68
+ - `rotation_optimizer.py`: Crop sequence optimization
69
+ - `image_generator.py`: Visualization generation
70
+ - `config.py`: System configuration
71
+
72
+ ### Frontend
73
+ - Bootstrap 5-based responsive UI
74
+ - Multi-panel input forms
75
+ - Interactive results dashboard
76
+ - Downloadable visualizations
77
+
78
+ ## API Endpoints
79
+
80
+ - `GET /`: Main simulation interface
81
+ - `POST /`: Submit simulation parameters
82
+ - `GET /api/health`: Health check endpoint
83
+
84
+ ## Data Sources (Production Ready)
85
+
86
+ This demo uses synthetic data stubs. In production, connect to:
87
+ - **Landsat 8/9 NDVI** via USGS Earth Explorer
88
+ - **MODIS NDVI/EVI** via NASA Earthdata
89
+ - **Open-Meteo** for weather forecasts
90
+ - **Copernicus** for terrain and soil data
91
+ - **USDA Ag Data Commons** for agricultural metadata
92
+
93
+ ## Technical Stack
94
+
95
+ - **Backend**: Python 3.10, Flask 3.0
96
+ - **Visualization**: Matplotlib 3.8
97
+ - **Data Processing**: NumPy 1.26
98
+ - **Deployment**: Docker on Hugging Face Spaces
99
+
100
+ ## MLOps Ready
101
+
102
+ - Single entry point architecture
103
+ - Clear module contracts for model swapping
104
+ - Environment-based configuration
105
+ - Health check monitoring
106
+ - Extensible for FastAPI integration
107
+
108
+ ## Future Enhancements
109
+
110
+ - Replace synthetic loaders with real satellite API integrations
111
+ - Implement actual TFT/Informer temporal models
112
+ - Deploy real MuZero RL agent for rotation optimization
113
+ - Add GAN/diffusion models for advanced crop imagery
114
+ - Multi-objective optimization (yield, profit, risk, sustainability)
115
+ - Historical comparison dashboards
116
+ - Export functionality for reports
117
+
118
+ ## License
119
+
120
+ MIT License - Feel free to use and modify for your agricultural AI projects!
121
+
122
+ ## Credits
123
+
124
+ Built as Feature 3 of an integrated agro-tech platform demonstrating future crop visualization capabilities.
app.py ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import uuid
3
+ from datetime import datetime
4
+ from flask import Flask, render_template, request, flash, url_for
5
+ from models.config import Config
6
+ from models.data_loader import DataManager
7
+ from models.temporal_forecaster import TemporalForecaster
8
+ from models.rotation_optimizer import CropRotationOptimizer
9
+ from models.image_generator import CropImageGenerator
10
+
11
+ def create_app():
12
+ app = Flask(__name__)
13
+ app.config["SECRET_KEY"] = os.environ.get("FLASK_SECRET_KEY", "dev-secret-key")
14
+ app.config["UPLOAD_FOLDER"] = os.path.join("static", "uploads")
15
+ app.config["GENERATED_FOLDER"] = os.path.join("static", "generated")
16
+
17
+ os.makedirs(app.config["UPLOAD_FOLDER"], exist_ok=True)
18
+ os.makedirs(app.config["GENERATED_FOLDER"], exist_ok=True)
19
+
20
+ data_manager = DataManager(Config)
21
+ forecaster = TemporalForecaster(Config)
22
+ optimizer = CropRotationOptimizer(Config)
23
+ image_generator = CropImageGenerator(Config)
24
+
25
+ @app.route("/", methods=["GET", "POST"])
26
+ def index():
27
+ if request.method == "POST":
28
+ try:
29
+ region = request.form.get("region") or "Field-001"
30
+ crop = request.form.get("crop") or "Maize"
31
+ seasons = int(request.form.get("seasons") or 2)
32
+ scenario = request.form.get("scenario") or "baseline"
33
+ start_date_str = request.form.get("start_date") or datetime.today().strftime("%Y-%m-%d")
34
+ start_date = datetime.strptime(start_date_str, "%Y-%m-%d")
35
+
36
+ rotation_plan_text = (request.form.get("rotation_plan") or "").strip()
37
+
38
+ rotation_file = request.files.get("rotation_file")
39
+ rotation_file_path = None
40
+ if rotation_file and rotation_file.filename:
41
+ filename = f"{uuid.uuid4().hex}_{rotation_file.filename}"
42
+ rotation_file_path = os.path.join(app.config["UPLOAD_FOLDER"], filename)
43
+ rotation_file.save(rotation_file_path)
44
+
45
+ ndvi_data = data_manager.load_ndvi_series(region=region)
46
+ weather_forecast = data_manager.load_weather_forecast(region=region)
47
+ soil_terrain = data_manager.load_soil_and_terrain(region=region)
48
+ commons_data = data_manager.load_ag_commons_metadata()
49
+
50
+ growth_forecast = forecaster.forecast_growth(
51
+ ndvi_data=ndvi_data,
52
+ weather=weather_forecast,
53
+ soil=soil_terrain,
54
+ crop=crop,
55
+ start_date=start_date,
56
+ seasons=seasons,
57
+ scenario=scenario,
58
+ )
59
+
60
+ optimized_rotation, rl_metrics = optimizer.optimize_rotation(
61
+ base_plan_text=rotation_plan_text,
62
+ uploaded_plan_path=rotation_file_path,
63
+ crop=crop,
64
+ seasons=seasons,
65
+ scenario=scenario,
66
+ )
67
+
68
+ img_filename = f"crop_sim_{uuid.uuid4().hex}.png"
69
+ img_path = os.path.join(app.config["GENERATED_FOLDER"], img_filename)
70
+ rel_img_path = os.path.join("generated", img_filename)
71
+
72
+ image_generator.generate_growth_visualization(
73
+ ndvi_series=ndvi_data,
74
+ forecast=growth_forecast,
75
+ rotation_plan=optimized_rotation,
76
+ output_path=img_path,
77
+ scenario=scenario,
78
+ )
79
+
80
+ metrics = {
81
+ "yield_index": growth_forecast.get("yield_index", 0.0),
82
+ "stress_risk": growth_forecast.get("stress_risk", 0.0),
83
+ "weather_volatility": growth_forecast.get("weather_volatility", 0.0),
84
+ "soil_score": growth_forecast.get("soil_score", 0.0),
85
+ }
86
+
87
+ return render_template(
88
+ "results.html",
89
+ region=region,
90
+ crop=crop,
91
+ seasons=seasons,
92
+ scenario=scenario,
93
+ start_date=start_date_str,
94
+ metrics=metrics,
95
+ rotation_plan=optimized_rotation,
96
+ rl_metrics=rl_metrics,
97
+ growth_forecast=growth_forecast,
98
+ image_path=rel_img_path,
99
+ commons_data=commons_data,
100
+ )
101
+ except Exception as e:
102
+ flash(f"Simulation failed: {e}", "danger")
103
+
104
+ regions = ["Field-001", "Field-002", "Field-Highland", "Field-Lowland"]
105
+ crops = ["Maize", "Wheat", "Rice", "Soybean", "Cotton"]
106
+ scenarios = [
107
+ ("baseline", "Baseline"),
108
+ ("wet_year", "Wet year (↑ rainfall)"),
109
+ ("dry_year", "Dry year (↓ rainfall)"),
110
+ ("heatwave", "Heatwave risk"),
111
+ ("low_inputs", "Low fertilizer / low inputs"),
112
+ ]
113
+ return render_template(
114
+ "index.html",
115
+ regions=regions,
116
+ crops=crops,
117
+ scenarios=scenarios,
118
+ today=datetime.today().strftime("%Y-%m-%d"),
119
+ )
120
+
121
+ @app.route("/api/health")
122
+ def health():
123
+ return {"status": "ok", "feature": "future_crop_visualization"}
124
+
125
+ return app
126
+
127
+ if __name__ == "__main__":
128
+ app = create_app()
129
+ app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5003)), debug=True)
models/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ from .config import Config
2
+ from .data_loader import DataManager
3
+ from .temporal_forecaster import TemporalForecaster
4
+ from .rotation_optimizer import CropRotationOptimizer
5
+ from .image_generator import CropImageGenerator
models/__pycache__/__init__.cpython-314.pyc ADDED
Binary file (442 Bytes). View file
 
models/__pycache__/config.cpython-314.pyc ADDED
Binary file (1.1 kB). View file
 
models/__pycache__/data_loader.cpython-314.pyc ADDED
Binary file (6.51 kB). View file
 
models/__pycache__/image_generator.cpython-314.pyc ADDED
Binary file (5.4 kB). View file
 
models/__pycache__/rotation_optimizer.cpython-314.pyc ADDED
Binary file (4.55 kB). View file
 
models/__pycache__/temporal_forecaster.cpython-314.pyc ADDED
Binary file (5.81 kB). View file
 
models/config.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ class Config:
4
+ DEVICE = "cpu"
5
+
6
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
7
+ DATA_DIR = os.path.join(BASE_DIR, "data")
8
+ CACHE_DIR = os.path.join(BASE_DIR, "cache")
9
+
10
+ os.makedirs(DATA_DIR, exist_ok=True)
11
+ os.makedirs(CACHE_DIR, exist_ok=True)
12
+
13
+ NDVI_LENGTH_DAYS = 120
14
+ MAX_SEASONS = 4
15
+ IMG_WIDTH = 800
16
+ IMG_HEIGHT = 400
models/data_loader.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from datetime import datetime, timedelta
3
+ import random
4
+ from dataclasses import dataclass
5
+ from typing import List, Dict
6
+
7
+ @dataclass
8
+ class NDVIPoint:
9
+ date: datetime
10
+ ndvi: float
11
+ evi: float
12
+
13
+ class DataManager:
14
+ def __init__(self, config_cls):
15
+ self.cfg = config_cls
16
+
17
+ def load_ndvi_series(self, region: str) -> List[NDVIPoint]:
18
+ days = self.cfg.NDVI_LENGTH_DAYS
19
+ today = datetime.today()
20
+ series = []
21
+ base = 0.5 + (hash(region) % 20) / 100.0
22
+ for i in range(days):
23
+ d = today - timedelta(days=days - i)
24
+ seasonal = 0.2 * (1 + (i / days))
25
+ noise = random.uniform(-0.05, 0.05)
26
+ ndvi = max(0.1, min(0.9, base + seasonal * 0.3 + noise))
27
+ evi = max(0.05, min(0.8, ndvi - 0.05 + random.uniform(-0.02, 0.02)))
28
+ series.append(NDVIPoint(date=d, ndvi=ndvi, evi=evi))
29
+ return series
30
+
31
+ def load_weather_forecast(self, region: str) -> Dict:
32
+ today = datetime.today()
33
+ forecast = []
34
+ for i in range(30):
35
+ d = today + timedelta(days=i)
36
+ temp = 20 + (hash(region + "t") % 8) + (i * 0.1)
37
+ rain = max(0.0, random.gauss(3.0, 2.0))
38
+ forecast.append(
39
+ {
40
+ "date": d.strftime("%Y-%m-%d"),
41
+ "tmax": round(temp + random.uniform(0, 4), 1),
42
+ "tmin": round(temp - random.uniform(4, 6), 1),
43
+ "rain": round(rain, 2),
44
+ }
45
+ )
46
+ volatility = sum(abs(day["tmax"] - day["tmin"]) for day in forecast) / len(forecast)
47
+ return {"region": region, "daily": forecast, "volatility": round(volatility, 2)}
48
+
49
+ def load_soil_and_terrain(self, region: str) -> Dict:
50
+ elevation = 100 + (hash(region + "elev") % 250)
51
+ slope = round(1 + (hash(region + "slope") % 14), 1)
52
+ texture = ["Sandy loam", "Clay loam", "Silty clay", "Loamy sand"][hash(region) % 4]
53
+ organic = round(1.0 + (hash(region + "org") % 40) / 10.0, 1)
54
+ drainage = ["Well drained", "Moderately drained", "Poorly drained"][hash(region) % 3]
55
+ score = max(0.0, min(1.0, 0.2 + organic / 10.0 + (15 - abs(slope - 5)) / 40.0))
56
+ return {
57
+ "elevation_m": elevation,
58
+ "slope_deg": slope,
59
+ "texture": texture,
60
+ "organic_matter_pct": organic,
61
+ "drainage": drainage,
62
+ "soil_score": round(score, 2),
63
+ }
64
+
65
+ def load_ag_commons_metadata(self) -> Dict:
66
+ return {
67
+ "sources": [
68
+ "Landsat 8/9 NDVI (synthetic stub)",
69
+ "MODIS NDVI/EVI (synthetic stub)",
70
+ "Open-Meteo weather forecast (offline stub)",
71
+ "Copernicus terrain + soil (offline stub)",
72
+ "USDA Ag Data Commons (offline stub)",
73
+ ],
74
+ "note": "Replace synthetic loaders with real API and dataset integrations for production.",
75
+ }
models/image_generator.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from typing import List, Dict
3
+ import matplotlib
4
+ matplotlib.use("Agg")
5
+ import matplotlib.pyplot as plt
6
+ from .data_loader import NDVIPoint
7
+
8
+ class CropImageGenerator:
9
+ def __init__(self, config_cls):
10
+ self.cfg = config_cls
11
+
12
+ def generate_growth_visualization(
13
+ self,
14
+ ndvi_series: List[NDVIPoint],
15
+ forecast: Dict,
16
+ rotation_plan: List[Dict],
17
+ output_path: str,
18
+ scenario: str,
19
+ ):
20
+ if not ndvi_series:
21
+ raise ValueError("NDVI series is empty")
22
+
23
+ dates = [p.date for p in ndvi_series]
24
+ ndvi_values = [p.ndvi for p in ndvi_series]
25
+ evi_values = [p.evi for p in ndvi_series]
26
+
27
+ timeline = forecast.get("growth_timeline", [])
28
+
29
+ fig, axes = plt.subplots(2, 2, figsize=(10, 6))
30
+ ax1, ax2, ax3, ax4 = axes.ravel()
31
+
32
+ ax1.plot(dates, ndvi_values, label="NDVI")
33
+ ax1.plot(dates, evi_values, linestyle="--", label="EVI")
34
+ ax1.set_title("Historical Vegetation Indices")
35
+ ax1.set_xlabel("Date")
36
+ ax1.set_ylabel("Index")
37
+ ax1.legend()
38
+ ax1.grid(True, alpha=0.3)
39
+
40
+ if timeline:
41
+ f_dates = [t["date"] for t in timeline]
42
+ growth_scores = [t["growth_score"] for t in timeline]
43
+ ax2.plot(f_dates, growth_scores)
44
+ ax2.set_title("Forecast Growth Trajectory")
45
+ ax2.set_xlabel("Date")
46
+ ax2.set_ylabel("Growth score")
47
+ ax2.tick_params(axis="x", rotation=45)
48
+ ax2.grid(True, alpha=0.3)
49
+
50
+ crops = [r["crop"] for r in rotation_plan]
51
+ health = [r.get("rotation_health", 0.5) for r in rotation_plan]
52
+ ax3.bar(range(len(crops)), health)
53
+ ax3.set_xticks(range(len(crops)))
54
+ ax3.set_xticklabels(crops, rotation=30, ha="right")
55
+ ax3.set_ylim(0, 1)
56
+ ax3.set_title("Rotation Health by Season")
57
+ ax3.set_ylabel("Health index")
58
+
59
+ yield_index = forecast.get("yield_index", 0.0)
60
+ stress_risk = forecast.get("stress_risk", 0.0)
61
+ soil_score = forecast.get("soil_score", 0.0)
62
+ crop_suggestions = forecast.get("crop_suggestions", [])[:3]
63
+
64
+ ax4.axis("off")
65
+ lines = [
66
+ f"Scenario: {scenario}",
67
+ f"Yield index: {yield_index:.2f}",
68
+ f"Stress risk: {stress_risk:.2f}",
69
+ f"Soil score: {soil_score:.2f}",
70
+ "",
71
+ "Top crop suggestions:",
72
+ ]
73
+ for s in crop_suggestions:
74
+ lines.append(f"- {s['crop']}: {s['suitability']:.2f}")
75
+ ax4.text(0.02, 0.98, "\n".join(lines), va="top", ha="left")
76
+
77
+ plt.tight_layout()
78
+ os.makedirs(os.path.dirname(output_path), exist_ok=True)
79
+ fig.savefig(output_path, dpi=120, bbox_inches="tight")
80
+ plt.close(fig)
models/rotation_optimizer.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict, List, Tuple
2
+ import random
3
+
4
+ class CropRotationOptimizer:
5
+ def __init__(self, config_cls):
6
+ self.cfg = config_cls
7
+
8
+ def optimize_rotation(
9
+ self,
10
+ base_plan_text: str,
11
+ uploaded_plan_path: str,
12
+ crop: str,
13
+ seasons: int,
14
+ scenario: str,
15
+ ) -> Tuple[List[Dict], Dict]:
16
+ plan: List[Dict] = []
17
+ lines = [l.strip() for l in base_plan_text.splitlines() if l.strip()]
18
+ for ln in lines:
19
+ parts = [p.strip() for p in ln.split(",")]
20
+ if len(parts) >= 2:
21
+ plan.append({"season": parts[0], "crop": parts[1]})
22
+ if not plan:
23
+ rotation = ["Maize", "Soybean", "Wheat", "Cover crop"]
24
+ for i in range(seasons):
25
+ plan.append({"season": f"Season {i+1}", "crop": rotation[i % len(rotation)]})
26
+
27
+ def score_plan(p: List[Dict]) -> float:
28
+ score = 0.0
29
+ legume = ["Soybean", "Pea"]
30
+ cereal = ["Maize", "Wheat", "Rice"]
31
+ for i, item in enumerate(p):
32
+ c = item["crop"]
33
+ if i > 0 and c == p[i - 1]["crop"]:
34
+ score -= 0.4
35
+ if i > 0 and p[i - 1]["crop"] in legume and c in cereal:
36
+ score += 0.3
37
+ if c in legume:
38
+ score += 0.1
39
+ if scenario == "dry_year":
40
+ for item in p:
41
+ if item["crop"] == "Rice":
42
+ score -= 0.3
43
+ return score
44
+
45
+ best_plan = plan
46
+ best_score = score_plan(plan)
47
+ visit_counts = 0
48
+ crops_space = ["Maize", "Wheat", "Rice", "Soybean", "Cotton", "Cover crop"]
49
+
50
+ for _ in range(80):
51
+ visit_counts += 1
52
+ candidate = [dict(x) for x in best_plan]
53
+ idx = random.randint(0, len(candidate) - 1)
54
+ candidate[idx]["crop"] = random.choice(crops_space)
55
+ sc = score_plan(candidate)
56
+ if sc > best_score:
57
+ best_score = sc
58
+ best_plan = candidate
59
+
60
+ rl_metrics = {
61
+ "best_score": round(best_score, 3),
62
+ "episodes": 1,
63
+ "simulated_rollouts": visit_counts,
64
+ "policy_entropy": round(random.uniform(0.2, 0.9), 3),
65
+ }
66
+
67
+ rotation_health = max(0.1, min(1.0, 0.5 + best_score / 3.0))
68
+ for item in best_plan:
69
+ item["rotation_health"] = round(rotation_health, 2)
70
+
71
+ return best_plan, rl_metrics
models/temporal_forecaster.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import List, Dict
2
+ from datetime import datetime, timedelta
3
+ import math
4
+ from .data_loader import NDVIPoint
5
+
6
+ class TemporalForecaster:
7
+ def __init__(self, config_cls):
8
+ self.cfg = config_cls
9
+
10
+ def forecast_growth(
11
+ self,
12
+ ndvi_data: List[NDVIPoint],
13
+ weather: Dict,
14
+ soil: Dict,
15
+ crop: str,
16
+ start_date: datetime,
17
+ seasons: int,
18
+ scenario: str,
19
+ ) -> Dict:
20
+ if not ndvi_data:
21
+ raise ValueError("No NDVI data available for forecasting")
22
+
23
+ avg_ndvi = sum(p.ndvi for p in ndvi_data) / len(ndvi_data)
24
+ max_ndvi = max(p.ndvi for p in ndvi_data)
25
+ soil_score = soil.get("soil_score", 0.5)
26
+ volatility = weather.get("volatility", 5.0)
27
+
28
+ scenario_modifiers = {
29
+ "baseline": 1.0,
30
+ "wet_year": 1.1,
31
+ "dry_year": 0.85,
32
+ "heatwave": 0.8,
33
+ "low_inputs": 0.9,
34
+ }
35
+ scen_mult = scenario_modifiers.get(scenario, 1.0)
36
+
37
+ base_yield = (avg_ndvi * 0.6 + max_ndvi * 0.4) * 2.5
38
+ yield_index = max(0.0, min(1.0, base_yield * soil_score * scen_mult))
39
+
40
+ stress_risk = max(0.0, min(1.0, (volatility / 20.0) + (1 - soil_score) * 0.4))
41
+ if scenario in ("dry_year", "heatwave"):
42
+ stress_risk = min(1.0, stress_risk + 0.2)
43
+
44
+ timeline = []
45
+ day = start_date
46
+ total_days = int(self.cfg.NDVI_LENGTH_DAYS * seasons / 2)
47
+ for i in range(total_days):
48
+ growth_phase = math.sin((i / total_days) * math.pi)
49
+ growth_phase = max(0.0, growth_phase)
50
+ growth_score = growth_phase * yield_index
51
+ stage = self._stage_from_progress((i + 1) / total_days)
52
+ timeline.append(
53
+ {
54
+ "date": day.strftime("%Y-%m-%d"),
55
+ "growth_score": round(growth_score, 3),
56
+ "stage": stage,
57
+ }
58
+ )
59
+ day += timedelta(days=1)
60
+
61
+ suggestions = self._suggest_crops(crop, soil_score, scenario)
62
+
63
+ return {
64
+ "yield_index": round(yield_index, 3),
65
+ "stress_risk": round(stress_risk, 3),
66
+ "weather_volatility": weather.get("volatility", 0.0),
67
+ "soil_score": soil_score,
68
+ "growth_timeline": timeline,
69
+ "crop_suggestions": suggestions,
70
+ }
71
+
72
+ def _stage_from_progress(self, frac: float) -> str:
73
+ if frac < 0.15:
74
+ return "Emergence"
75
+ if frac < 0.35:
76
+ return "Vegetative"
77
+ if frac < 0.6:
78
+ return "Flowering"
79
+ if frac < 0.85:
80
+ return "Grain filling"
81
+ return "Maturity"
82
+
83
+ def _suggest_crops(self, current_crop: str, soil_score: float, scenario: str):
84
+ base_options = ["Maize", "Wheat", "Rice", "Soybean", "Cotton"]
85
+ suggestions = []
86
+ for c in base_options:
87
+ if c == current_crop:
88
+ continue
89
+ score = soil_score
90
+ if c in ("Rice",) and scenario == "dry_year":
91
+ score -= 0.2
92
+ if c in ("Cotton",) and scenario == "wet_year":
93
+ score -= 0.1
94
+ suggestions.append({"crop": c, "suitability": round(max(0.1, min(1.0, score)), 2)})
95
+ suggestions.sort(key=lambda x: x["suitability"], reverse=True)
96
+ return suggestions
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ flask
2
+ matplotlib
3
+ numpy
4
+ pandas
static/css/style.css ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ background-color: #f5f7fa;
3
+ }
4
+
5
+ .card-header {
6
+ background-color: #0d6efd;
7
+ color: #fff;
8
+ }
9
+
10
+ .metric-pill {
11
+ display: flex;
12
+ justify-content: space-between;
13
+ align-items: center;
14
+ padding: 0.35rem 0.75rem;
15
+ border-radius: 999px;
16
+ background: #0d6efd0f;
17
+ margin-bottom: 0.4rem;
18
+ }
19
+
20
+ .metric-pill .label {
21
+ font-size: 0.85rem;
22
+ color: #555;
23
+ }
24
+
25
+ .metric-pill .value {
26
+ font-weight: 600;
27
+ }
28
+
29
+ .growth-timeline {
30
+ max-height: 200px;
31
+ overflow-y: auto;
32
+ border: 1px solid #dee2e6;
33
+ border-radius: 0.5rem;
34
+ padding: 0.4rem 0.75rem;
35
+ }
36
+
37
+ .growth-item {
38
+ display: flex;
39
+ justify-content: space-between;
40
+ font-size: 0.8rem;
41
+ padding: 0.15rem 0;
42
+ border-bottom: 1px dashed #efefef;
43
+ }
44
+
45
+ .growth-item:last-child {
46
+ border-bottom: none;
47
+ }
48
+
49
+ .growth-item .date {
50
+ width: 30%;
51
+ color: #555;
52
+ }
53
+ .growth-item .stage {
54
+ width: 40%;
55
+ font-weight: 500;
56
+ }
57
+ .growth-item .score {
58
+ width: 20%;
59
+ text-align: right;
60
+ color: #0d6efd;
61
+ }
static/generated/crop_sim_1ea1f560731b4c84b365fe0cbfb5a411.png ADDED

Git LFS Details

  • SHA256: c8fbe46e53a45d4585b43bf2fe2b7b86b8cb0597b0cc7c1492d24325b289272d
  • Pointer size: 131 Bytes
  • Size of remote file: 162 kB
static/js/main.js ADDED
@@ -0,0 +1 @@
 
 
1
+ // Placeholder for future interactive UI enhancements
templates/base.html ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <title>{% block title %}Future Crop Simulator{% endblock %}</title>
7
+ <link
8
+ href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
9
+ rel="stylesheet"
10
+ />
11
+ <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}" />
12
+ </head>
13
+ <body>
14
+ <nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-3">
15
+ <div class="container-fluid">
16
+ <a class="navbar-brand" href="{{ url_for('index') }}">Agro Feature 3 – Future Crop</a>
17
+ </div>
18
+ </nav>
19
+
20
+ <div class="container-fluid">
21
+ {% with messages = get_flashed_messages(with_categories=true) %}
22
+ {% if messages %}
23
+ {% for category, message in messages %}
24
+ <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
25
+ {{ message }}
26
+ <button type="button" class="btn-close" data-bs-dismiss="="alert" aria-label="Close"></button>
27
+ </div>
28
+ {% endfor %}
29
+ {% endif %}
30
+ {% endwith %}
31
+
32
+ {% block content %}{% endblock %}
33
+ </div>
34
+
35
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
36
+ <script src="{{ url_for('static', filename='js/main.js') }}"></script>
37
+ </body>
38
+ </html>
templates/index.html ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends "base.html" %}
2
+ {% block title %}Future Crop Simulation{% endblock %}
3
+ {% block content %}
4
+ <div class="row">
5
+ <div class="col-lg-4">
6
+ <div class="card shadow-sm mb-3">
7
+ <div class="card-header fw-bold">Simulation Inputs</div>
8
+ <div class="card-body">
9
+ <form method="post" enctype="multipart/form-data">
10
+ <div class="mb-3">
11
+ <label class="form-label">Region / Field ID</label>
12
+ <select name="region" class="form-select">
13
+ {% for r in regions %}
14
+ <option value="{{ r }}">{{ r }}</option>
15
+ {% endfor %}
16
+ </select>
17
+ </div>
18
+ <div class="mb-3">
19
+ <label class="form-label">Primary Crop</label>
20
+ <select name="crop" class="form-select">
21
+ {% for c in crops %}
22
+ <option value="{{ c }}">{{ c }}</option>
23
+ {% endfor %}
24
+ </select>
25
+ </div>
26
+ <div class="mb-3">
27
+ <label class="form-label">Start date</label>
28
+ <input type="date" name="start_date" class="form-control" value="{{ today }}"/>
29
+ </div>
30
+ <div class="mb-3">
31
+ <label class="form-label">Seasons to simulate</label>
32
+ <input type="number" name="seasons" min="1" max="4" value="2" class="form-control" />
33
+ </div>
34
+ <div class="mb-3">
35
+ <label class="form-label">Scenario</label>
36
+ <select name="scenario" class="form-select">
37
+ {% for val, label in scenarios %}
38
+ <option value="{{ val }}">{{ label }}</option>
39
+ {% endfor %}
40
+ </select>
41
+ <div class="form-text">
42
+ Run “what-if” simulations: dry/wet year, heatwaves, low inputs, etc.
43
+ </div>
44
+ </div>
45
+
46
+ <hr />
47
+ <h6>Crop Rotation / Planting Schedule</h6>
48
+ <div class="mb-3">
49
+ <label class="form-label">Inline plan (Season, Crop)</label>
50
+ <textarea
51
+ name="rotation_plan"
52
+ rows="6"
53
+ class="form-control"
54
+ placeholder="Season 1, Maize
55
+ Season 2, Soybean
56
+ Season 3, Wheat"
57
+ ></textarea>
58
+ <div class="form-text">
59
+ You can also upload a CSV version below.
60
+ </div>
61
+ </div>
62
+ <div class="mb-3">
63
+ <label class="form-label">Upload rotation CSV (optional)</label>
64
+ <input type="file" name="rotation_file" class="form-control" />
65
+ </div>
66
+
67
+ <div class="d-grid">
68
+ <button class="btn btn-success" type="submit">
69
+ Run Future Crop Simulation
70
+ </button>
71
+ </div>
72
+ </form>
73
+ </div>
74
+ </div>
75
+ </div>
76
+
77
+ <div class="col-lg-8">
78
+ <div class="card shadow-sm mb-3">
79
+ <div class="card-header fw-bold">Feature 3 – Generative Future Crop Visualization</div>
80
+ <div class="card-body">
81
+ <p>
82
+ This feature combines synthetic NDVI/EVI time series, weather forecast, soil & terrain profiles,
83
+ and your crop rotation plan to generate future crop growth simulations.
84
+ </p>
85
+ <ul>
86
+ <li>Simulated crop growth imagery (multi-panel figure)</li>
87
+ <li>Multi-season crop rotation simulations and health indicators</li>
88
+ <li>Growth stage predictions along a timeline</li>
89
+ <li>What-if scenario visualizations (dry / wet / heatwave / low input)</li>
90
+ <li>Crop selection suggestions based on soil and climate profiles</li>
91
+ <li>RL-style optimization stats for rotation planning</li>
92
+ </ul>
93
+ <p class="text-muted mb-0">
94
+ In your full stack system, this module can be called via REST from FastAPI or integrated into a unified
95
+ agro-features dashboard.
96
+ </p>
97
+ </div>
98
+ </div>
99
+
100
+ <div class="card shadow-sm">
101
+ <div class="card-header fw-bold">How it works (Architecture Overview)</div>
102
+ <div class="card-body small">
103
+ <div class="row">
104
+ <div class="col-md-6">
105
+ <h6>Backend Data</h6>
106
+ <ul>
107
+ <li>Historical NDVI/EVI (synthetic stub)</li>
108
+ <li>Weather forecast (Open-Meteo compatible)</li>
109
+ <li>Terrain &amp; soil (Copernicus-style)</li>
110
+ <li>Ag Data Commons-style metadata</li>
111
+ </ul>
112
+ </div>
113
+ <div class="col-md-6">
114
+ <h6>Model Stack</h6>
115
+ <ul>
116
+ <li>Temporal forecaster stub (TFT / Informer ready)</li>
117
+ <li>RL rotation optimizer (MuZero-style API)</li>
118
+ <li>GAN / diffusion-like visualization (matplotlib multi-panel)</li>
119
+ <li>End-to-end MLOps ready: single entry point, clear contracts</li>
120
+ </ul>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ </div>
127
+ {% endblock %}
templates/results.html ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends "base.html" %}
2
+ {% block title %}Simulation Results{% endblock %}
3
+ {% block content %}
4
+ <div class="row mb-3">
5
+ <div class="col-md-12">
6
+ <a href="{{ url_for('index') }}" class="btn btn-link">&larr; Back to inputs</a>
7
+ </div>
8
+ </div>
9
+
10
+ <div class="row">
11
+ <div class="col-lg-4">
12
+ <div class="card shadow-sm mb-3">
13
+ <div class="card-header fw-bold">Run Summary</div>
14
+ <div class="card-body">
15
+ <p class="mb-1"><strong>Region:</strong> {{ region }}</p>
16
+ <p class="mb-1"><strong>Crop:</strong> {{ crop }}</p>
17
+ <p class="mb-1"><strong>Seasons:</strong> {{ seasons }}</p>
18
+ <p class="mb-1"><strong>Scenario:</strong> {{ scenario }}</p>
19
+ <p class="mb-1"><strong>Start date:</strong> {{ start_date }}</p>
20
+ </div>
21
+ </div>
22
+
23
+ <div class="card shadow-sm mb-3">
24
+ <div class="card-header fw-bold">Key Metrics</div>
25
+ <div class="card-body">
26
+ <div class="metric-pill">
27
+ <span class="label">Yield index</span>
28
+ <span class="value">{{ metrics.yield_index }}</span>
29
+ </div>
30
+ <div class="metric-pill">
31
+ <span class="label">Stress risk</span>
32
+ <span class="value">{{ metrics.stress_risk }}</span>
33
+ </div>
34
+ <div class="metric-pill">
35
+ <span class="label">Weather volatility</span>
36
+ <span class="value">{{ metrics.weather_volatility }}</span>
37
+ </div>
38
+ <div class="metric-pill">
39
+ <span class="label">Soil score</span>
40
+ <span class="value">{{ metrics.soil_score }}</span>
41
+ </div>
42
+ </div>
43
+ </div>
44
+
45
+ <div class="card shadow-sm mb-3">
46
+ <div class="card-header fw-bold">RL Optimizer (MuZero-style)</div>
47
+ <div class="card-body small">
48
+ <p class="mb-1"><strong>Best score:</strong> {{ rl_metrics.best_score }}</p>
49
+ <p class="mb-1"><strong>Episodes:</strong> {{ rl_metrics.episodes }}</p>
50
+ <p class="mb-1"><strong>Simulated rollouts:</strong> {{ rl_metrics.simulated_rollouts }}</p>
51
+ <p class="mb-1"><strong>Policy entropy:</strong> {{ rl_metrics.policy_entropy }}</p>
52
+ <p class="text-muted mt-2 mb-0">
53
+ These are synthetic RL-style stats from a local search optimizer. Swap in a
54
+ real MuZero agent later without changing the UI.
55
+ </p>
56
+ </div>
57
+ </div>
58
+ </div>
59
+
60
+ <div class="col-lg-8">
61
+ <div class="card shadow-sm mb-3">
62
+ <div class="card-header fw-bold">Simulated Crop Growth Imagery</div>
63
+ <div class="card-body text-center">
64
+ <img
65
+ src="{{ url_for('static', filename=image_path) }}"
66
+ class="img-fluid rounded border"
67
+ alt="Simulated crop growth visualization"
68
+ />
69
+ </div>
70
+ </div>
71
+
72
+ <div class="card shadow-sm mb-3">
73
+ <div class="card-header fw-bold">Optimized Crop Rotation Plan</div>
74
+ <div class="card-body">
75
+ <div class="table-responsive">
76
+ <table class="table table-sm align-middle mb-0">
77
+ <thead>
78
+ <tr>
79
+ <th>Season</th>
80
+ <th>Crop</th>
81
+ <th>Rotation health</th>
82
+ </tr>
83
+ </thead>
84
+ <tbody>
85
+ {% for row in rotation_plan %}
86
+ <tr>
87
+ <td>{{ row.season }}</td>
88
+ <td>{{ row.crop }}</td>
89
+ <td>
90
+ <span class="badge bg-success-subtle text-success-emphasis">
91
+ {{ row.rotation_health }}
92
+ </span>
93
+ </td>
94
+ </tr>
95
+ {% endfor %}
96
+ </tbody>
97
+ </table>
98
+ </div>
99
+ </div>
100
+ </div>
101
+
102
+ <div class="card shadow-sm mb-3">
103
+ <div class="card-header fw-bold">Growth Stage Predictions</div>
104
+ <div class="card-body small">
105
+ <div class="growth-timeline">
106
+ {% for g in growth_forecast.growth_timeline[:60] %}
107
+ <div class="growth-item">
108
+ <span class="date">{{ g.date }}</span>
109
+ <span class="stage">{{ g.stage }}</span>
110
+ <span class="score">{{ g.growth_score }}</span>
111
+ </div>
112
+ {% endfor %}
113
+ </div>
114
+ <p class="text-muted mt-2 mb-0">
115
+ Showing first 60 days of predicted stages and growth scores. The full timeline is
116
+ available through the backend API.
117
+ </p>
118
+ </div>
119
+ </div>
120
+
121
+ <div class="card shadow-sm mb-3">
122
+ <div class="card-header fw-bold">Crop Selection Suggestions</div>
123
+ <div class="card-body small">
124
+ <ul class="mb-1">
125
+ {% for s in growth_forecast.crop_suggestions %}
126
+ <li>
127
+ <strong>{{ s.crop }}</strong> – suitability {{ s.suitability }}
128
+ </li>
129
+ {% endfor %}
130
+ </ul>
131
+ <p class="text-muted mb-0">
132
+ These are derived from soil score and scenario assumptions. In a full model you would
133
+ plug in multi-objective optimization (yield, profit, risk).
134
+ </p>
135
+ </div>
136
+ </div>
137
+
138
+ <div class="card shadow-sm mb-3">
139
+ <div class="card-header fw-bold">Backend Data Sources</div>
140
+ <div class="card-body small">
141
+ <ul class="mb-1">
142
+ {% for s in commons_data.sources %}
143
+ <li>{{ s }}</li>
144
+ {% endfor %}
145
+ </ul>
146
+ <p class="text-muted mb-0">
147
+ {{ commons_data.note }}
148
+ </p>
149
+ </div>
150
+ </div>
151
+ </div>
152
+ </div>
153
+ {% endblock %}