Download app.py from bapi143/CropAI: direct link, hf CLI and curl.
- Browser
- Download file 3.07 kB
-
https://huggingface.co/spaces/bapi143/CropAI/resolve/main/app.py
- Command line
-
hf download hf://spaces/bapi143/CropAI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/bapi143/CropAI/resolve/main/app.py
3.07 kB
| # -*- 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 | |
| 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" | |
| } | |
| ) | |