Spaces:
Sleeping
Sleeping
|
Download README.md from low-key-007/yoloapi: direct link, hf CLI and curl.
- Browser
- Download file 5.71 kB
-
https://huggingface.co/spaces/low-key-007/yoloapi/resolve/main/README.md
- Command line
-
hf download hf://spaces/low-key-007/yoloapi/README.md
-
curl -L -o README.md https://huggingface.co/spaces/low-key-007/yoloapi/resolve/main/README.md
5.71 kB
| title: Yoloapi | |
| emoji: π | |
| colorFrom: indigo | |
| colorTo: blue | |
| sdk: docker | |
| pinned: false | |
| license: mit | |
| Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference | |
| # πΎ AgriVision: Precision Weed & Crop Detection System | |
|  | |
|  | |
|  | |
|  | |
|  | |
| > **AgriVision** is a high-performance computer vision system designed to automate the differentiation between crops and invasive weeds. It serves as the intelligent backend for autonomous agricultural robotics and drone surveillance, aiming to reduce herbicide usage by up to 90% through precision targeting. | |
| --- | |
| ## π Table of Contents | |
| 1. [Project Overview](#-project-overview) | |
| 2. [System Architecture](#-system-architecture) | |
| 3. [Key Features](#-key-features) | |
| 4. [Tech Stack](#-tech-stack) | |
| 5. [Installation & Setup](#-installation--setup) | |
| 6. [API Documentation](#-api-documentation) | |
| 7. [Project Structure](#-project-structure) | |
| 8. [Developer's Note](#-developers-note) | |
| --- | |
| ## π Project Overview | |
| Modern agriculture faces a dual challenge: maximizing yield while minimizing environmental impact. Traditional "blanket spraying" of herbicides is inefficient and ecologically damaging. | |
| **AgriVision** addresses this by enabling **Site-Specific Weed Management (SSWM)**. By processing visual data in real-time, the system identifies the exact coordinates of weeds versus crops, allowing robotic actuators to target only the invasive plants. | |
| ### Impact Goals: | |
| * **π± Sustainability:** Drastic reduction in chemical runoff. | |
| * **π° Economic Efficiency:** Lower input costs for farmers. | |
| * **β‘ Real-Time Processing:** Optimized for edge deployment (e.g., NVIDIA Jetson). | |
| --- | |
| ## π System Architecture | |
| The system is built on a **Microservice Architecture**, encapsulating the State-of-the-Art (SOTA) **YOLOv8** model within a scalable **FastAPI** container. | |
| ### High-Level Data Flow | |
| 1. **Input:** Edge devices (drones/cameras) send raw image frames via REST API. | |
| 2. **Preprocessing:** Images are resized (640px) and normalized. | |
| 3. **Inference:** The YOLOv8x model (loaded in memory) performs object detection. | |
| 4. **Post-Processing:** Bounding boxes are drawn, and JSON metadata is extracted. | |
| 5. **Response:** The client receives both the analytical data and the visualized result. | |
| ### π Architecture Diagram | |
| ```mermaid | |
| graph TD | |
| subgraph "Client Layer" | |
| Drone[π Agricultural Drone] | |
| App[π± Mobile Dashboard] | |
| end | |
| subgraph "FastAPI Container" | |
| API[π API Gateway] | |
| subgraph "Inference Engine" | |
| Pre[βοΈ Preprocessor] | |
| Model{π§ YOLOv8 Model} | |
| Post[π¨ Annotator & JSON Builder] | |
| end | |
| end | |
| subgraph "Data & Weights" | |
| Weights[(π¦ Model Weights .pt)] | |
| end | |
| Drone -->|POST /predict (Image)| API | |
| App -->|POST /predict (Image)| API | |
| API --> Pre | |
| Pre -->|Tensor| Model | |
| Weights -.->|Load on Startup| Model | |
| Model -->|Raw Detections| Post | |
| Post -->|JSON + Base64| API | |
| API -->|Response| Drone | |
| API -->|Response| App | |
| Key Features | |
| Real-Time Inference: Optimized pipeline ensures low latency responses (<200ms on GPU). | |
| Dual Output: Returns both structured data (JSON for robots) and visual overlays (Images for humans). | |
| Confidence Filtering: Configurable thresholds to minimize false positives. | |
| Containerized: Fully Dockerized for "Write Once, Run Anywhere" deployment. | |
| Scalable: Stateless design allows horizontal scaling using Kubernetes or Cloud Run. | |
| Component,Technology,Rationale | |
| Model,Ultralytics YOLOv8x,chosen for highest mAP (Mean Average Precision) over speed. | |
| Backend,FastAPI,"Asynchronous, strict typing (Pydantic), and auto-documentation." | |
| Image Proc,Pillow (PIL),Efficient image manipulation and format conversion. | |
| Container,Docker,Ensures consistent environment across dev and production. | |
| Server,Uvicorn,Lightning-fast ASGI server implementation. | |
| π‘ API Documentation | |
| POST /predict | |
| Upload an image to get detection results. | |
| Request: multipart/form-data | |
| file: The image file (JPEG/PNG) | |
| Response Example (JSON): | |
| JSON | |
| { | |
| "meta": { | |
| "count": 2, | |
| "model": "YOLOv8-X", | |
| "inference_time": "0.14s" | |
| }, | |
| "detections": [ | |
| { | |
| "class_id": 0, | |
| "label": "weed", | |
| "confidence": 0.94, | |
| "bbox": [120.5, 300.2, 180.1, 410.5] | |
| } | |
| ], | |
| "annotated_image_base64": "iVBORw0KGgoAAAANSUhEUgAA..." | |
| } | |
| π¨βπ» Developer's Note | |
| To the Admissions Committee & Reviewers: | |
| This repository represents the final, consolidated production version (v2.1) of my work on agricultural computer vision. | |
| In the spirit of Clean Code and professional engineering practices, I have refactored the experimental notebooks into this deployable microservice. My development journey involved extensive experimentation with: | |
| Comparing YOLOv5 vs YOLOv8 architectures. | |
| Fine-tuning Non-Maximum Suppression (NMS) thresholds. | |
| Optimizing Docker image layers for faster cold starts. | |
| For access to the raw training logs, dataset preparation scripts, or previous experimental branches, please refer to my Archived Research Repository. | |
| or can see the outputs in kaggle notebooks "https://www.kaggle.com/code/omgwhatisthis/yolov8x-weed-crop-detection" |