# quocbao2772004/autograde architecture

> Architecture diagram of the GitHub repository quocbao2772004/autograde, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/quocbao2772004/autograde
- Repository: https://github.com/quocbao2772004/autograde

## Overview

##### Project Type & Purpose
- This is a full-stack (backend mainly) automated grading tool. Its purpose is to process scanned answer sheets by first using image processing (via OpenCV) to detect and extract answer regions, then applying a CNN model (with deep learning techniques) to determine marked answers. Finally, it compares the detected responses against a predefined answer key (in CSV format) to compute scores.
- The key functionalities include image processing, deep learning inference, and result evaluation/report generation.

##### Analyzing the File Structure
- Top-Level Files & Folders:
- README.md: Provides project overview, installation, and usage guidelines.
- answer_key.csv: The configurable answer key.
- The “code” directory: Contains the main scripts (process_image.py) and Jupyter notebook (create_answer_file.ipynb) used for running the image processing and evaluation procedures.
- The “cropped_images” directory: Stores intermediate processed images, likely organized into sub-folders (e.g., I, II, III, sbd) for different forms or regions.
- The “dataset” directory: Likely contains raw or processed data used for training/validation.
- The “model” directory: Contains the CNN code (modelCNN.py) and the associated pre-trained weights (weight.h5).

##### Core Components & Relationships
a. Input / Data Acquisition:
- Scanned answer sheets (supplied by the user) serve as input.

b. Image Processing Module:
- Implemented in process_image.py (and possibly assisted by OpenCV routines).
- Functions include detecting answer regions and cropping/mapping the images.
- Processed outputs are stored in the “cropped_images” directory.

c. Answer Key Component:
- Uses answer_key.csv which holds the correct answers.
- Likely read using Pandas within the Python scripts.

d. Deep Learning Module:
- Encompasses the CNN model defined in modelCNN.py.
- Uses the pre-trained weight file (weight.h5) for inference.
- Processes locally cropped images for marking detection.

e. Answer Evaluation & Reporting Module:
- Compares the CNN’s outputs with the answer key.
- Generates a final grading report automatically.
- May be integrated within process_image.py or triggered separately (see create_answer_file.ipynb).

##### Architectural Patterns & Technologies
- Modular design:
- Separation between the image pre-processing (OpenCV) and the classification/inference components (CNN).
- Clear dependency on CSV-based configuration (answer key) which makes grading customizable.
- Underline the use of external libraries and frameworks:
- Python is the base language.
- OpenCV is key for image processing.
- Pandas is used for data handling.
- The CNN model leverages deep learning frameworks (most likely TensorFlow or Keras, implied by the use of .h5 weights).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Scanned Answer Sheets"]:::input
    B["Image Processing (OpenCV)"]:::process
    C["Cropped Images Storage"]:::storage
    E["Answer Key (CSV)"]:::storage
    F["Grading & Reports"]:::evaluation

    subgraph "Deep Learning Module"
        D1["CNN Model Inference"]:::ai
        D2["Weights"]:::ai
    end

    A -->|"processes"| B
    B -->|"outputs to"| C
    C -->|"feeds into"| D1
    D1 -->|"utilizes"| D2
    D2 -->|"results passed to"| F
    E -->|"provides key to"| F

    click B "https://github.com/quocbao2772004/autograde/blob/main/code/process_image.py"
    click C "https://github.com/quocbao2772004/autograde/tree/main/cropped_images/"
    click E "https://github.com/quocbao2772004/autograde/blob/main/answer_key.csv"
    click D1 "https://github.com/quocbao2772004/autograde/blob/main/model/modelCNN.py"
    click D2 "https://github.com/quocbao2772004/autograde/blob/main/model/weight.h5"
    click F "https://github.com/quocbao2772004/autograde/blob/main/code/create_answer_file.ipynb"

    classDef input fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef process fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef storage fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef ai fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef evaluation fill:#FFB6C1,stroke:#333,stroke-width:2px;
```
