# gayitrijarajapu/automatic-image-caption-generator architecture

> Architecture diagram of the GitHub repository gayitrijarajapu/automatic-image-caption-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gayitrijarajapu/automatic-image-caption-generator
- Repository: https://github.com/gayitrijarajapu/automatic-image-caption-generator

## Overview

This is a Streamlit image-captioning app. A user submits an image and language through the browser interface; the Python app validates the request, runs object detection and image captioning, optionally translates the caption, and returns results for display and browser-based speech. The main workflow and model calls are visible in app.py. The README documents browser voice output and the supplied interface, but frontend/index.html was not excerpted, so its internal behavior is not mapped.

Main entry points: [`app.py`](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py) (Request handling), [`frontend/index.html`](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/frontend/index.html) (Browser interface), [`yolov8m.pt`](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/yolov8m.pt) (YOLO weights)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_browser_ui["Browser interface<br/>[index.html]"]
end

subgraph group_application["App workflow"]
  node_request_handler["Request handling<br/>[app.py]"]
  node_image_prep["Image preparation<br/>[app.py]"]
  node_response_state["Session response<br/>[app.py]"]
end

subgraph group_inference["Image inference"]
  node_model_loader["Cached model loader<br/>[app.py]"]
  node_yolo_weights["YOLO weights<br/>[yolov8m.pt]"]
  node_object_detection["Object detection<br/>[app.py]"]
  node_blip_model["BLIP caption model"]
  node_caption_generation["Caption generation<br/>[app.py]"]
end

subgraph group_outputs["Caption outputs"]
  node_object_results["Detected objects<br/>[app.py]"]
  node_translation["Caption translation<br/>[app.py]"]
  node_translator_service["Google Translate"]
  node_browser_speech["Browser speech"]
end

node_user(("User"))

node_user -->|"submits image"| node_browser_ui
node_browser_ui -->|"sends request"| node_request_handler
node_request_handler -->|"decodes image"| node_image_prep
node_request_handler -->|"analyzes image"| node_object_detection
node_request_handler -->|"analyzes image"| node_caption_generation
node_image_prep -->|"provides image"| node_object_detection
node_image_prep -->|"provides image"| node_caption_generation
node_object_detection -->|"loads detector"| node_model_loader
node_caption_generation -->|"loads captioner"| node_model_loader
node_model_loader -->|"loads weights"| node_yolo_weights
node_object_detection -->|"extracts detections"| node_object_results
node_caption_generation -->|"runs inference"| node_blip_model
node_request_handler -->|"translates caption"| node_translation
node_translation -->|"requests translation"| node_translator_service
node_request_handler -->|"stores response"| node_response_state
node_response_state -->|"returns results"| node_browser_ui
node_browser_ui -->|"speaks caption"| node_browser_speech

click node_browser_ui "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/frontend/index.html"
click node_request_handler "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py"
click node_image_prep "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py"
click node_model_loader "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py"
click node_yolo_weights "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/yolov8m.pt"
click node_object_detection "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py"
click node_caption_generation "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py"
click node_object_results "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py"
click node_translation "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py"
click node_response_state "https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser_ui,node_user toneBlue
class node_request_handler,node_image_prep,node_response_state toneAmber
class node_model_loader,node_yolo_weights,node_object_detection,node_blip_model,node_caption_generation toneMint
class node_object_results,node_translation,node_translator_service,node_browser_speech toneRose
```

## Components

### User interface

- [Browser interface](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/frontend/index.html): `frontend/index.html`

### App workflow

- [Request handling](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py): `app.py`
- [Image preparation](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py): `app.py`
- [Session response](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py): `app.py`

### Image inference

- [Cached model loader](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py): `app.py`
- [YOLO weights](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/yolov8m.pt): `yolov8m.pt`
- [Object detection](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py): `app.py`
- **BLIP caption model**
- [Caption generation](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py): `app.py`

### Caption outputs

- [Detected objects](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py): `app.py`
- [Caption translation](https://github.com/gayitrijarajapu/automatic-image-caption-generator/blob/main/app.py): `app.py`
- **Google Translate**
- **Browser speech**

### Other components

- **User**

## Connections

- User → Browser interface: submits image (evidence: `README.md`)
- Browser interface → Request handling: sends request (evidence: `app.py`)
- Request handling → Image preparation: decodes image (evidence: `app.py`)
- Request handling → Object detection: analyzes image (evidence: `app.py`)
- Request handling → Caption generation: analyzes image (evidence: `app.py`)
- Image preparation → Object detection: provides image (evidence: `app.py`)
- Image preparation → Caption generation: provides image (evidence: `app.py`)
- Object detection → Cached model loader: loads detector (evidence: `app.py`)
- Caption generation → Cached model loader: loads captioner (evidence: `app.py`)
- Cached model loader → YOLO weights: loads weights (evidence: `app.py`)
- Object detection → Detected objects: extracts detections (evidence: `app.py`)
- Caption generation → BLIP caption model: runs inference (evidence: `app.py`)
- Request handling → Caption translation: translates caption (evidence: `app.py`)
- Caption translation → Google Translate: requests translation (evidence: `app.py`)
- Request handling → Session response: stores response (evidence: `app.py`)
- Session response → Browser interface: returns results (evidence: `app.py`)
- Browser interface → Browser speech: speaks caption (evidence: `README.md`)
