# harmandugri15/visionnarrator architecture

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

- Interactive diagram: https://gitdiagram.com/harmandugri15/visionnarrator
- Repository: https://github.com/harmandugri15/visionnarrator

## Overview

VisionNarrator is an image-captioning and story-generation project: it prepares Flickr30k data, uses a ViT/GPT-2 captioning model, then offers semantic analysis and grounded story generation. The README documents the data, model, training, and evaluation workflow; the source excerpts show the dataset readers and the semantic/story components. Notebook-backed stages are represented using their exact paths, but their internal calls are not inferred where source was not sampled.

Main entry points: [`notebooks/10_final_application.ipynb`](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/10_final_application.ipynb) (Image caption), [`src/storytelling.py`](https://github.com/harmandugri15/visionnarrator/blob/main/src/storytelling.py) (Story generator), [`notebooks/04_vit_training.ipynb`](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/04_vit_training.ipynb) (Model training), [`src/semantics.py`](https://github.com/harmandugri15/visionnarrator/blob/main/src/semantics.py) (Scene representation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_flickr[("Flickr30k data")]
  node_prep["Dataset preparation"]
  node_dataset["Image datasets<br/>[vision_data.py]"]
end

subgraph group_caption["Captioning model"]
  node_vit["ViT encoder"]
  node_training["Model training"]
  node_transfer["Transfer learning"]
  node_decoder["GPT-2 decoder"]
  node_checkpoint["Captioner weights<br/>[vit_captioner.pt]"]
  node_evaluation["Caption evaluation"]
  node_captionresult["Image caption"]
end

subgraph group_semantics["Semantic analysis"]
  node_semantic["Semantic extraction<br/>[semantics.py]"]
  node_semanticnotebook["Semantic workflow"]
  node_representation["Scene representation<br/>[semantics.py]"]
end

subgraph group_stories["Story generation"]
  node_generator["Story generator<br/>[storytelling.py]"]
  node_grounder["Story grounding<br/>[storytelling.py]"]
  node_storynotebook["Story workflow"]
  node_story["Generated story"]
end

node_user(("Image user"))
node_language_model["Instruction-tuned LLM"]

node_flickr -->|"prepares splits"| node_prep
node_prep -->|"provides image data"| node_dataset
node_user -.->|"requests description"| node_captionresult
node_dataset -.->|"supplies images"| node_vit
node_vit -->|"trains encoder"| node_training
node_training -->|"supports transfer"| node_transfer
node_transfer -->|"uses decoder"| node_decoder
node_training -.->|"saves weights"| node_checkpoint
node_checkpoint -.->|"supports inference"| node_captionresult
node_decoder -.->|"generates caption"| node_captionresult
node_captionresult -->|"evaluates captions"| node_evaluation
node_captionresult -.->|"analyzes caption"| node_semantic
node_semanticnotebook -->|"extracts scene"| node_representation
node_semantic -->|"builds representation"| node_representation
node_representation -->|"provides story context"| node_generator
node_generator -->|"loads and queries"| node_language_model
node_generator -.->|"checks story"| node_grounder
node_grounder -.->|"requests repair"| node_generator
node_storynotebook -.->|"produces stories"| node_story
node_grounder -.->|"grounds output"| node_story

click node_prep "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/02_data_preprocessing.ipynb"
click node_dataset "https://github.com/harmandugri15/visionnarrator/blob/main/src/vision_data.py"
click node_vit "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/03_vit_from_scratch.ipynb"
click node_training "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/04_vit_training.ipynb"
click node_transfer "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/05_transfer_learning_vit.ipynb"
click node_decoder "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/06_gpt2_decoder.ipynb"
click node_checkpoint "https://github.com/harmandugri15/visionnarrator/blob/main/src/models/vit_captioner.pt"
click node_evaluation "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/07_model_evaluation.ipynb"
click node_captionresult "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/10_final_application.ipynb"
click node_semantic "https://github.com/harmandugri15/visionnarrator/blob/main/src/semantics.py"
click node_semanticnotebook "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/08_semantic_understanding.ipynb"
click node_representation "https://github.com/harmandugri15/visionnarrator/blob/main/src/semantics.py"
click node_generator "https://github.com/harmandugri15/visionnarrator/blob/main/src/storytelling.py"
click node_grounder "https://github.com/harmandugri15/visionnarrator/blob/main/src/storytelling.py"
click node_storynotebook "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/09_story_generation.ipynb"
click node_story "https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/10_final_application.ipynb"

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_flickr,node_prep,node_dataset,node_user toneBlue
class node_vit,node_training,node_transfer,node_decoder,node_checkpoint,node_evaluation,node_captionresult toneAmber
class node_semantic,node_semanticnotebook,node_representation toneMint
class node_generator,node_grounder,node_storynotebook,node_story toneRose
class node_language_model toneIndigo
```

## Components

### Data preparation

- **Flickr30k data**
- [Dataset preparation](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/02_data_preprocessing.ipynb): `notebooks/02_data_preprocessing.ipynb`
- [Image datasets](https://github.com/harmandugri15/visionnarrator/blob/main/src/vision_data.py): `src/vision_data.py`

### Captioning model

- [ViT encoder](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/03_vit_from_scratch.ipynb): `notebooks/03_vit_from_scratch.ipynb`
- [Model training](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/04_vit_training.ipynb): `notebooks/04_vit_training.ipynb`
- [Transfer learning](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/05_transfer_learning_vit.ipynb): `notebooks/05_transfer_learning_vit.ipynb`
- [GPT-2 decoder](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/06_gpt2_decoder.ipynb): `notebooks/06_gpt2_decoder.ipynb`
- [Captioner weights](https://github.com/harmandugri15/visionnarrator/blob/main/src/models/vit_captioner.pt): `src/models/vit_captioner.pt`
- [Caption evaluation](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/07_model_evaluation.ipynb): `notebooks/07_model_evaluation.ipynb`
- [Image caption](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/10_final_application.ipynb): `notebooks/10_final_application.ipynb`

### Semantic analysis

- [Semantic extraction](https://github.com/harmandugri15/visionnarrator/blob/main/src/semantics.py): `src/semantics.py`
- [Semantic workflow](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/08_semantic_understanding.ipynb): `notebooks/08_semantic_understanding.ipynb`
- [Scene representation](https://github.com/harmandugri15/visionnarrator/blob/main/src/semantics.py): `src/semantics.py`

### Story generation

- [Story generator](https://github.com/harmandugri15/visionnarrator/blob/main/src/storytelling.py): `src/storytelling.py`
- [Story grounding](https://github.com/harmandugri15/visionnarrator/blob/main/src/storytelling.py): `src/storytelling.py`
- [Story workflow](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/09_story_generation.ipynb): `notebooks/09_story_generation.ipynb`
- [Generated story](https://github.com/harmandugri15/visionnarrator/blob/main/notebooks/10_final_application.ipynb): `notebooks/10_final_application.ipynb`

### Other components

- **Image user**
- **Instruction-tuned LLM**

## Connections

- Flickr30k data → Dataset preparation: prepares splits (evidence: `README.md`)
- Dataset preparation → Image datasets: provides image data (evidence: `README.md`)
- Image user → Image caption: requests description
- Image datasets → ViT encoder: supplies images
- ViT encoder → Model training: trains encoder (evidence: `README.md`)
- Model training → Transfer learning: supports transfer (evidence: `README.md`)
- Transfer learning → GPT-2 decoder: uses decoder (evidence: `README.md`)
- Model training → Captioner weights: saves weights
- Captioner weights → Image caption: supports inference
- GPT-2 decoder → Image caption: generates caption
- Image caption → Caption evaluation: evaluates captions (evidence: `README.md`)
- Image caption → Semantic extraction: analyzes caption
- Semantic workflow → Scene representation: extracts scene (evidence: `src/semantics.py`)
- Semantic extraction → Scene representation: builds representation (evidence: `src/semantics.py`)
- Scene representation → Story generator: provides story context (evidence: `src/storytelling.py`)
- Story generator → Instruction-tuned LLM: loads and queries (evidence: `src/storytelling.py`)
- Story generator → Story grounding: checks story (evidence: `src/storytelling.py`)
- Story grounding → Story generator: requests repair (evidence: `src/storytelling.py`)
- Story workflow → Generated story: produces stories
- Story grounding → Generated story: grounds output
