# p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection architecture

> Architecture diagram of the GitHub repository p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection
- Repository: https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection

## Overview

- Data Source & Ingestion:
– Block for “Data Repository” indicating the dataset of ~30,000 images (fresh and spoilt produce) from Kaggle.
– “Data Preprocessing” component which handles image resizing, normalization, and splitting (training, testing, hold-out validation).
- Experimental Model Development:
– A module “Deep CNN Models” that further branches into subcomponents noted in notebooks (e.g., ResNet50, TensorFlowCNN, EfficientNet_binary).
– “Contrastive Learning Module” representing experiments with contrastive learning techniques.
– “SVM Classification Module” for the alternative machine learning approach.
– “LLM-Based Approaches” with subcomponents for “Zero-Shot” and “Few-Shot” experiments, representing the integration of vision–language models.
- Evaluation & Testing:
– An “Evaluation” or “Model Validation” component that listens to outputs from training modules and measures performance (accuracy between fresh and spoilt classification).
- Inference & Deployment (Future Direction):
– Even though deployment isn’t explicitly implemented, include a “Deployment/Inference Pipeline” that could eventually feed into quality control systems, smart refrigeration, or produce sorting mechanisms.
- Documentation & External References:
– Optionally, a component or annotation that indicates external sources (research papers, Medium posts, Kaggle datasets) which informed the design and experimental setups.

##### Relationships and Data Flow
– Start with the data source flowing into the “Data Preprocessing” block.
- Interactions such as model training feedback loops (e.g., performance metrics feeding back for hyperparameter tuning).

##### Architectural Patterns and Design Principles
- Separation of Concerns: Distinct blocks for data handling, model experimentation, and evaluation.
- Modularity: Each experiment (CNN variants, contrastive learning, SVM, LLM-based approaches) is shown as an independent module, making it easy to compare or extend.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Handling
    subgraph "Data Handling"
        DataRepo["Data Repository (30,000 images)"]:::data
        DataPrep["Data Preprocessing"]:::data
    end

    %% Experimental Model Development
    subgraph "Experimental Model Development"
        subgraph "Deep CNN Models"
            ResNet50["ResNet50"]:::ml
            TensorFlowCNN["TensorFlowCNN"]:::ml
            Efficientnet["EfficientNet_binary"]:::ml
        end
        Contrastive["Contrastive Learning Module"]:::ml
        SVM["SVM Classification Module"]:::ml
        subgraph "LLM-Based Approaches"
            ZeroShot["Zero-Shot Experiment"]:::ml
            FewShot["Few-Shot Experiment"]:::ml
        end
    end

    %% Evaluation & Deployment
    Eval["Evaluation & Validation"]:::eval
    Deploy["Deployment/Inference Pipeline"]:::deploy

    %% Data Flow
    DataRepo --> DataPrep
    DataPrep --> ResNet50
    DataPrep --> TensorFlowCNN
    DataPrep --> Efficientnet
    DataPrep --> Contrastive
    DataPrep --> SVM
    DataPrep --> ZeroShot
    DataPrep --> FewShot

    ResNet50 --> Eval
    TensorFlowCNN --> Eval
    Efficientnet --> Eval
    Contrastive --> Eval
    SVM --> Eval
    ZeroShot --> Eval
    FewShot --> Eval

    Eval --> Deploy

    %% Click Events
    click DataRepo "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/README.md"
    click DataRepo "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/FreshProducePDF.pdf"
    click DataRepo "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/ProjectProposal.pdf"
    click ResNet50 "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/FinalCodes/Resnet50_binary.ipynb"
    click TensorFlowCNN "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/FinalCodes/TensorFlowCNN.ipynb"
    click Efficientnet "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/FinalCodes/Efficientnet_binary.ipynb"
    click Contrastive "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/FinalCodes/ContrastiveLearning.ipynb"
    click SVM "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/FinalCodes/SVM.ipynb"
    click ZeroShot "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/FinalCodes/LLM_Zero_Shot.ipynb"
    click FewShot "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/FinalCodes/LLM_Few_Shot.ipynb"
    click Deploy "https://github.com/p-twinkle/perishpredict-smart-vision-for-produce-spoilage-detection/blob/main/README.md"

    %% Styles
    classDef data fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef ml fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef eval fill:#D5F5E3,stroke:#1D8348,stroke-width:2px;
    classDef deploy fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
