# julilc/computer_vision architecture

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

- Interactive diagram: https://gitdiagram.com/julilc/computer_vision
- Repository: https://github.com/julilc/computer_vision

## Overview

##### Project type and purpose
- This is a machine-learning inference and vector-search application with a Gradio-based UI.
- It uses YOLOv8 for object detection on dog images, produces embeddings via three model variants (base, custom, fine-tuned), stores them in FAISS vector indexes, and exposes an interactive Gradio front end.

##### File structure
- Top-level:
- app_gradio/ – four Gradio application scripts for experimentation or different UI flows.
- models/ – serialized model artifacts: YOLOv8 (“yolov8n.pt”) plus two Keras-based custom models and two fine-tuned variants (.h5 & .keras).
- test_img/ – a YOLOv8 dataset (images + labels + YAML) for validation.
- vector_db/ – FAISS indexes and pickled vector stores for each model variant.
- dogs.csv & informe_jupyter.ipynb – auxiliary data and analysis notebook.
- No external microservices, but key “components” appear as separate directories.

##### README
- Empty/placeholder. No architectural guidance here, so we infer from code structure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RawImages["Raw Images"]:::data
        LabeledData["Labeled Dataset"]:::data
        DatasetConfig["Dataset Configuration (data.yaml)"]:::data
        TabularData["Dog Metadata (dogs.csv)"]:::data
    end

    %% Training & Embedding Layer
    subgraph "Training & Embedding Generation"
        direction TB
        YOLOProcess["YOLOv8 Training/Inference"]:::training
        EmbeddingExtractor["Embedding Extractor"]:::training
    end

    %% Model Storage
    subgraph "Model Storage"
        direction TB
        YOLOModel["YOLOv8 Base Model"]:::storage
        CustomModel_h5["Custom Keras Model (.h5)"]:::storage
        CustomModel_keras["Custom Keras Model (.keras)"]:::storage
        FineTune_h5["Fine-Tuned Keras Model (.h5)"]:::storage
        FineTune_keras["Fine-Tuned Keras Model (.keras)"]:::storage
    end

    %% Vector Database Layer
    subgraph "Vector Database Layer"
        direction TB
        subgraph "Base Model Vectors"
            direction TB
            BaseIndex["vector_index_train.faiss"]:::vector
            BaseVectors["vector_dogs_db.pkl"]:::vector
        end
        subgraph "Custom Model Vectors"
            direction TB
            CustomIndex["vector_index_custom_model.faiss"]:::vector
            CustomVectors["vector_dogs_custom_db.pkl"]:::vector
        end
        subgraph "Fine-Tuned Model Vectors"
            direction TB
            FineTuneIndex["vector_index_fine_tuning_model.faiss"]:::vector
            FineTuneVectors["vector_dogs_fine_tuning_db.pkl"]:::vector
        end
    end

    %% Application & UI Layer
    subgraph "Application Layer"
        direction TB
        Gradio1["Gradio App 1"]:::app
        Gradio2["Gradio App 2"]:::app
        Gradio3["Gradio App 3"]:::app
        Gradio4["Gradio App 4"]:::app
    end

    User["End User"]:::user

    %% Relationships
    RawImages -->|provides images| YOLOProcess
    LabeledData -->|provides labels| YOLOProcess
    DatasetConfig -->|configures| YOLOProcess
    TabularData -->|metadata| EmbeddingExtractor

    YOLOProcess -->|generates features| EmbeddingExtractor
    EmbeddingExtractor -->|saves model files| YOLOModel
    EmbeddingExtractor -->|saves model files| CustomModel_h5
    EmbeddingExtractor -->|saves model files| CustomModel_keras
    EmbeddingExtractor -->|saves model files| FineTune_h5
    EmbeddingExtractor -->|saves model files| FineTune_keras

    YOLOModel -->|indexed by| BaseIndex
    YOLOModel -->|vector store| BaseVectors

    CustomModel_h5 -->|indexed by| CustomIndex
    CustomModel_keras -->|indexed by| CustomIndex
    CustomModel_h5 -->|vector store| CustomVectors
    CustomModel_keras -->|vector store| CustomVectors

    FineTune_h5 -->|indexed by| FineTuneIndex
    FineTune_keras -->|indexed by| FineTuneIndex
    FineTune_h5 -->|vector store| FineTuneVectors
    FineTune_keras -->|vector store| FineTuneVectors

    BaseIndex <-->|search queries| Gradio1
    BaseVectors <-->|search queries| Gradio1
    CustomIndex <-->|search queries| Gradio2
    CustomVectors <-->|search queries| Gradio2
    FineTuneIndex <-->|search queries| Gradio3
    FineTuneVectors <-->|search queries| Gradio3
    BaseIndex <-->|search queries| Gradio4
    BaseVectors <-->|search queries| Gradio4

    Gradio1 -->|serves UI| User
    Gradio2 -->|serves UI| User
    Gradio3 -->|serves UI| User
    Gradio4 -->|serves UI| User

    %% Click Events
    click RawImages "https://github.com/julilc/computer_vision/tree/master/test_img/raw_images"
    click LabeledData "https://github.com/julilc/computer_vision/tree/master/test_img/YOLOv8_images"
    click DatasetConfig "https://github.com/julilc/computer_vision/blob/master/test_img/YOLOv8_images/data.yaml"
    click TabularData "https://github.com/julilc/computer_vision/blob/master/dogs.csv"
    click YOLOModel "https://github.com/julilc/computer_vision/blob/master/models/yolov8n.pt"
    click CustomModel_h5 "https://github.com/julilc/computer_vision/blob/master/models/custom_model.h5"
    click CustomModel_keras "https://github.com/julilc/computer_vision/blob/master/models/custom_model.keras"
    click FineTune_h5 "https://github.com/julilc/computer_vision/blob/master/models/finetuning_model.h5"
    click FineTune_keras "https://github.com/julilc/computer_vision/blob/master/models/finetuning_model.keras"
    click BaseIndex "https://github.com/julilc/computer_vision/blob/master/vector_db/base_model/vector_index_train.faiss"
    click BaseVectors "https://github.com/julilc/computer_vision/blob/master/vector_db/base_model/vector_dogs_db.pkl"
    click CustomIndex "https://github.com/julilc/computer_vision/blob/master/vector_db/custom_model/vector_index_custom_model.faiss"
    click CustomVectors "https://github.com/julilc/computer_vision/blob/master/vector_db/custom_model/vector_dogs_custom_db.pkl"
    click FineTuneIndex "https://github.com/julilc/computer_vision/blob/master/vector_db/fine_tuning_model/vector_index_fine_tuning_model.faiss"
    click FineTuneVectors "https://github.com/julilc/computer_vision/blob/master/vector_db/fine_tuning_model/vector_dogs_fine_tuning_db.pkl"
    click Gradio1 "https://github.com/julilc/computer_vision/blob/master/app_gradio/app_gradio_1.py"
    click Gradio2 "https://github.com/julilc/computer_vision/blob/master/app_gradio/app_gradio_2.py"
    click Gradio3 "https://github.com/julilc/computer_vision/blob/master/app_gradio/app_gradio_3.py"
    click Gradio4 "https://github.com/julilc/computer_vision/blob/master/app_gradio/app_gradio_4.py"

    %% Styles
    classDef data fill:#cce5ff,stroke:#4da3ff,color:#004085;
    classDef training fill:#d4edda,stroke:#28a745,color:#155724;
    classDef storage fill:#e2e3e5,stroke:#6c757d,color:#383d41,stroke-dasharray: 5 5;
    classDef vector fill:#fff3cd,stroke:#ffcd39,color:#856404;
    classDef app fill:#f5c6cb,stroke:#ff6f6f,color:#721c24;
    classDef user fill:#d1ecf1,stroke:#17a2b8,color:#0c5460;
```
