File size: 3,069 Bytes
5fd7795 8d356f8 5fd7795 8d356f8 5fd7795 8d356f8 5fd7795 8d356f8 5fd7795 2f4b890 5fd7795 0ee27f7 5fd7795 b4b1776 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | # -*- coding: utf-8 -*-
"""
CropAI Hugging Face Spaces Entry Point (Gradio + FastAPI ZeroGPU Compatible)
Mounts CropAI Enterprise FastAPI Server inside Hugging Face Gradio Space.
Provides:
1. Public interactive Web Landing Page
2. Interactive Swagger REST API documentation at '/docs'
3. All 30 Production REST Endpoints for CropAI Flutter Mobile App at '/api/v1/...'
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
import gradio as gr
from backend.main import app as backend_app
# ZeroGPU Startup Detection Handler
try:
import spaces
@spaces.GPU
def zero_gpu_pipeline(x: str = "") -> str:
"""Keeps Hugging Face ZeroGPU environment verified and active."""
return f"CropAI ZeroGPU Pipeline Active: {x}"
except Exception:
def zero_gpu_pipeline(x: str = "") -> str:
return f"CropAI CPU Pipeline Active: {x}"
# Web Landing Page for visitors opening the Space in browser
with gr.Blocks(title="๐พ CropAI Agronomic Cloud") as demo:
gr.Markdown("# ๐พ CropAI: Autonomous Plant Pathology & Advisory Ecosystem")
gr.Markdown("""
### ๐ Cloud Inference Backend is Active & Running 24/7!
This Hugging Face Space hosts the production cloud inference backend for the **CropAI Mobile Application**.
---
### ๐ฑ Mobile App Connection Settings:
In your Flutter app (`frontend/lib/config/app_config.dart`), set:
```dart
static const String productionCloudUrl = "https://bapi143-cropai.hf.space";
static String baseUrl = productionCloudUrl;
```
---
### ๐ Quick Links:
* ๐ **[Interactive Swagger API Docs](/docs)** โ Test all 30 REST endpoints directly in browser
* ๐ฉบ **[Backend Health Check](/health)** โ Verify active AI model and system status
* ๐พ **[Detectable Crops Catalog](/api/v1/crops)** โ View 127+ supported pathologies
* ๐ **[Dataset Platforms Catalog](/api/v1/datasets/platforms)** โ 338,000+ benchmark image samples
---
### ๐ง Active AI & Multi-Engine Suite:
* **Multimodal Vision:** Google Gemini 3.8 Flash (Cascading Failover)
* **Leaf Spectroscopy:** Early Chlorophyll Breakdown & Botanical Gatekeeper
* **Bio-Acoustics AI:** Deep Learning Audio-CNN & Log Mel-Spectrogram Stem Pest Eavesdropper
* **Pest Detection Engine:** AgroAI YOLO11 Small (IP102 Benchmark Deep Learning)
* **Bio-Twinโข:** Thermodynamic Dew-Point & Spore Germination Index (SGI)
* **Thermal Shock AI:** Nocturnal Radiation Frost ($T \\le 2^\\circ\\text{C}$) & Terminal Heatwave Defense
* **Solar IoT Hub:** LoRaWAN Telemetry Ingestion, Dual-Depth Soil VWC, PWP Drought Alarms
* **Drone VRA:** Autonomous Spot-Spraying Lawnmower Grid Generator
""")
if __name__ == "__main__":
demo.launch(
ssr_mode=False,
app_kwargs={
"routes": list(backend_app.routes),
"docs_url": "/docs",
"redoc_url": "/redoc",
"title": "CropAI Agricultural Cloud API",
"version": "1.2.0"
}
)
|