Edge-Deployed Vision Models Combined with LLMs: Building an Intelligent Crop Disease and Pest Diagnosis System

    As smart agriculture advances, agricultural technology stations and large-scale farms demand faster and more accurate disease and pest diagnosis. Traditional manual inspection is labor-intensive, while standalone visual recognition can classify diseases but cannot provide in-depth treatment advice. This article explores an integrated crop disease and pest diagnosis system that combines edge-side visual object detection with a domain-specific large language model (LLM), covering its technical architecture, business features, and engineering practices.

    Edge-Deployed Vision Models Combined with LLMs: Building an Intelligent Crop Disease and Pest Diagnosis System

    As smart agriculture continues to mature, agricultural technology stations and large planting bases are placing higher demands on the efficiency and accuracy of disease and pest diagnosis. Traditional manual inspection is time-consuming and labor-intensive, while standalone visual recognition technology—although capable of classifying diseases—struggles to provide in-depth treatment recommendations. This article takes a deep dive into an integrated intelligent crop disease and pest diagnosis system that fuses edge-side visual object detection with an industry-focused large language model (LLM), covering its technical architecture, business features, and engineering practices.

    1. Core Technical Architecture and Model Collaboration

    The system adopts an “edge-cloud” architecture with multi-model collaboration, balancing real-time response in edge scenarios with the professional advisory capabilities of LLMs.

    1.1 Edge-Side Visual Object Detection Model

    On the vision side, the system integrates state-of-the-art end-to-end object detection algorithms (such as single-stage detection network architectures). These models are lightweight enough to be deployed on edge computing devices or local servers, enabling fast visual inference even when offline. Using non-maximum suppression (NMS) and anchor box mechanisms, the models can accurately localize lesion regions on leaves and output corresponding confidence scores. This offline inference capability minimizes the impact of network latency on detection efficiency, making it particularly well-suited for field environments with unstable network conditions.

    1.2 Industry LLM Integration

    A vision model can only answer “what is it,” while agricultural technicians need to know “how to treat it.” The system’s backend connects to an open-source LLM with strong natural language processing capabilities. Once the vision model outputs a disease or pest category, the system converts it into a structured prompt and feeds it to the LLM, which—drawing on an agricultural plant protection knowledge base—generates an in-depth diagnostic report covering causes of the disease, transmission pathways, recommended pesticides, and preventive measures. This “visual perception + cognitive reasoning” collaboration significantly enhances the system’s practical value.

    2. Core Features and Business Scenario Adaptation

    To meet the actual workflow requirements of agricultural stations and planting bases, the system is designed with closed-loop data management and collaborative work in mind.

    2.1 Multi-Source Data Ingestion and Batch Processing

    The system supports multiple data input methods, including bulk local image upload, direct photo capture from mobile devices, and importing screenshots from third-party monitoring systems. The backend uses an asynchronous task queue mechanism: when a large number of concurrent sample requests arrive, detection tasks are pushed into a message queue for load leveling, ensuring system stability under high load.

    2.2 Visual Statistics and PDF Report Export

    After detection is complete, the system not only displays bounding-box results for individual images but also automatically aggregates detection data for the entire batch. Using data visualization, it generates pie charts, bar charts, and other statistics that clearly show the distribution and severity of each disease type.

    In addition, the system includes a built-in report generation engine that exports detection results, LLM-generated treatment advice, and visualization charts into a standardized PDF file with one click. Below is the core pseudocode logic for report generation:

    1. def generate_pdf_report(detection_result, llm_advice):
    2. # Initialize the PDF document object
    3. pdf_doc = PDFDocument()
    4. # Add basic information and detection overview
    5. pdf_doc.add_title("Crop Disease and Pest Intelligent Detection Report")
    6. pdf_doc.add_text(f"Detection time: {datetime.now()}")
    7. pdf_doc.add_image(detection_result.annotated_image)
    8. # Insert LLM-generated treatment recommendations
    9. pdf_doc.add_section("AI Plant Protection Recommendations")
    10. pdf_doc.add_text(llm_advice)
    11. # Build and return the file stream
    12. return pdf_doc.build_stream()

    This feature makes it easy for field staff to archive results, compile summaries, and submit reports to supervising organizations.

    2.3 Role-Based Permissions and Multi-User Collaboration

    The system implements role-based access control (RBAC) with a well-structured hierarchical permission framework. Through a three-layer mapping of users, roles, and permissions, strict data isolation is achieved. For example, regular technicians can only view and operate on detection data for the areas they are responsible for, while station managers have access to global data aggregation and personnel management. This design effectively safeguards data security and supports multi-user online collaboration.

    3. Frontend Engineering and Highly Customizable Design

    Given the diverse usage habits of agricultural technicians and the variety of terminal devices, the frontend follows a modular and highly configurable design philosophy.

    3.1 Dynamic Themes and Layout Adjustment

    The frontend uses CSS variables to enable dynamic theme color switching, allowing users to adjust interface brightness based on ambient lighting or personal preference. The page layout uses a grid system, and component dimensions (such as sidebar width and image preview area ratios) are all drag-adjustable, balancing aesthetics with usability.

    3.2 Responsive Adaptation

    The frontend framework supports responsive layout, automatically adapting to PCs, tablets, and large display terminals to ensure a smooth interactive experience across different scenarios.

    4. Crop Disease Recognition Capabilities and Coverage

    Trained on a massive dataset of agricultural images, the vision model currently supports recognition of 37 crop health states and common diseases, covering major cash crops and staple food crops. The specific categories are:

    • Apple: Black rot, Healthy, Scab
    • Bell pepper: Bacterial spot, Healthy
    • Cassava: Brown streak disease, Bacterial blight, Green mite disease, Healthy, Mosaic disease
    • Cherry: Healthy, Powdery mildew
    • Corn: Leaf spot, Common rust, Healthy, Northern leaf blight
    • Grape: Black rot, Healthy, Leaf blight (Esca)
    • Citrus: Huanglongbing (citrus greening)
    • Peach: Bacterial spot, Healthy
    • Potato: Early blight, Healthy, Late blight
    • Rice: Brown spot, Healthy, Blast
    • Strawberry: Powdery mildew, Healthy, Leaf scorch
    • Tomato: Bacterial spot, Early blight, Late blight, Healthy, Leaf mold, Septoria leaf spot

    This rich classification system allows the system to be widely applied across various agricultural scenarios, meeting detection needs across regions and crop types.

    5. Cloud Deployment and Infrastructure Support

    For large-scale deployment, the system can leverage mature cloud-native infrastructure to improve overall availability. For example, object storage services such as those from Baidu AI Cloud can be used to persist large volumes of disease images and PDF reports; container platforms enable elastic scaling of both LLM inference services and vision detection services; and cloud logging and monitoring/alerting mechanisms provide real-time visibility into system health. The integration of cloud resources enables efficient coordination between local edge devices and the cloud “brain,” building a stable and reliable foundation for smart agriculture detection.

    6. Conclusion and Outlook

    This crop disease and pest diagnosis system, which fuses edge-side visual detection with a large language model, successfully connects the full business chain from “image capture → intelligent recognition → knowledge Q&A → report generation.” Offline visual inference ensures usability in field-level scenarios, while the LLM provides professional plant protection advisory capabilities. Combined with robust permission management, batch processing, and a customizable frontend design, the system offers a valuable engineering reference for the digital transformation of modern agriculture. In the future, as multimodal LLM technology continues to evolve, the system is expected to achieve deeper fusion of images and text, driving crop disease diagnosis toward greater intelligence and precision.