# hmzask/codsoft-ai_caption_generate architecture

> Architecture diagram of the GitHub repository hmzask/codsoft-ai_caption_generate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hmzask/codsoft-ai_caption_generate
- Repository: https://github.com/hmzask/codsoft-ai_caption_generate

## Overview

This is a small Streamlit image-captioning app. A user uploads an image; the app normalizes it, invokes the caption model on request, and displays the generated caption. The model loads Microsoft Florence-2-base through Hugging Face Transformers and prepares, generates, and post-processes the caption. The README describes CPU-focused use, while the implementation selects CUDA when available. The graph follows the sampled calls; the README also documents model download and CPU performance considerations, but no separate runtime subsystem for those concerns appears in the tree.

Main entry points: [`app.py`](https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/app.py) (Streamlit app), [`models/caption_model.py`](https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/models/caption_model.py) (Caption model), [`utils/image_utils.py`](https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/utils/image_utils.py) (Image loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["Streamlit app<br/>[app.py]"]
end

subgraph group_image["Image preparation"]
  node_image_loader["Image loader<br/>[image_utils.py]"]
end

subgraph group_inference["Caption inference"]
  node_caption_model["Caption model<br/>[caption_model.py]"]
end

node_user(("User"))
node_florence["Florence-2-base"]

node_user -->|"uploads image"| node_app
node_app -->|"loads image"| node_image_loader
node_app -->|"requests caption"| node_caption_model
node_caption_model -->|"loads checkpoint"| node_florence
node_app -->|"displays caption"| node_user

click node_app "https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/app.py"
click node_image_loader "https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/utils/image_utils.py"
click node_caption_model "https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/models/caption_model.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_app,node_user toneBlue
class node_image_loader toneAmber
class node_caption_model toneMint
class node_florence toneIndigo
```

## Components

### User interface

- [Streamlit app](https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/app.py): `app.py`

### Image preparation

- [Image loader](https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/utils/image_utils.py): `utils/image_utils.py`

### Caption inference

- [Caption model](https://github.com/hmzask/codsoft-ai_caption_generate/blob/main/models/caption_model.py): `models/caption_model.py`

### Other components

- **User**
- **Florence-2-base**

## Connections

- User → Streamlit app: uploads image (evidence: `app.py`)
- Streamlit app → Image loader: loads image (evidence: `app.py`)
- Streamlit app → Caption model: requests caption (evidence: `app.py`)
- Caption model → Florence-2-base: loads checkpoint (evidence: `models/caption_model.py`)
- Streamlit app → User: displays caption (evidence: `app.py`)
