# bobbibao/ocsd-thesis architecture

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

- Interactive diagram: https://gitdiagram.com/bobbibao/ocsd-thesis
- Repository: https://github.com/bobbibao/ocsd-thesis

## Overview

OCSD is a sketch-and-text-guided scene image generation research system: it turns object descriptions and a scene sketch into an image intended to preserve object identity, count, layout, and relationships. The interactive path runs from user input through sketch parsing and OCSD preparation/generation to a consistency check and displayed image. The broader experiment path builds benchmark scenes, runs competing generation methods, evaluates images, and reports comparisons. The README documents additional baselines, ablations, and quality metrics; unsampled implementation details are shown only where supported by that documentation.

Main entry points: [`ocsd/metrics.py`](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/metrics.py) (Image metrics), [`ocsd/method.py`](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/method.py) (OCSD preparation and generation), [`ocsd/stages.py`](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/stages.py) (Experiment stages), [`ocsd/app.py`](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/app.py) (Gradio interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Scene input"]
  node_app["Gradio interface<br/>[app.py]"]
  node_sketch["Sketch and prompt parsing<br/>[sketch.py]"]
  node_scene_data["Benchmark scenes<br/>[data.py]"]
end

subgraph group_generation["Generation"]
  node_method["OCSD preparation and generation<br/>[method.py]"]
  node_methods["Baseline methods<br/>[methods.py]"]
  node_engine["Diffusion engine<br/>[engine.py]"]
  node_attention["Attention control<br/>[attention.py]"]
  node_vision["Vision models<br/>[vision.py]"]
  node_config["Generation configuration<br/>[config.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_matching["Object consistency matching<br/>[matching.py]"]
  node_metrics["Image metrics<br/>[metrics.py]"]
  node_report["Statistical reports<br/>[report.py]"]
end

subgraph group_experiments["Experiments"]
  node_runner["Experiment runner<br/>[runner.py]"]
  node_artifacts["Generated images and logs<br/>[runner.py]"]
  node_stages["Experiment stages<br/>[stages.py]"]
  node_results["Experiment result files<br/>[stages.py]"]
end

node_user(("Sketch and text user"))
node_external_data(("QuickDraw and COCO"))

node_user -->|"provides input"| node_app
node_app -->|"parses sketch"| node_sketch
node_app -->|"prepares and generates"| node_method
node_app -->|"checks detections"| node_vision
node_app -->|"checks consistency"| node_matching
node_external_data -.->|"provides samples"| node_scene_data
node_stages -->|"builds benchmarks"| node_scene_data
node_stages -->|"runs experiments"| node_runner
node_stages -->|"evaluates images"| node_metrics
node_stages -->|"builds reports"| node_report
node_runner -->|"loads scenes"| node_scene_data
node_runner -->|"runs OCSD"| node_method
node_runner -->|"runs baselines"| node_methods
node_runner -->|"writes images and logs"| node_artifacts
node_method -->|"uses scene prompts"| node_sketch
node_method -->|"selects and checks objects"| node_vision
node_method -->|"denoises and composes"| node_engine
node_method -->|"uses settings"| node_config
node_engine -->|"uses processors"| node_attention
node_methods -->|"uses diffusion engine"| node_engine
node_metrics -->|"reads generated images"| node_artifacts
node_metrics -->|"loads references"| node_scene_data
node_metrics -->|"detects and scores"| node_vision
node_metrics -->|"computes consistency"| node_matching
node_metrics -->|"writes per-image metrics"| node_results
node_report -->|"reads metrics"| node_results
node_report -->|"writes summaries and tables"| node_results
node_stages -->|"records experiment outputs"| node_results

click node_app "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/app.py"
click node_sketch "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/sketch.py"
click node_scene_data "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/data.py"
click node_runner "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/runner.py"
click node_method "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/method.py"
click node_methods "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/methods.py"
click node_engine "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/engine.py"
click node_attention "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/attention.py"
click node_vision "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/vision.py"
click node_config "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/config.py"
click node_artifacts "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/runner.py"
click node_matching "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/matching.py"
click node_metrics "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/metrics.py"
click node_report "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/report.py"
click node_stages "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/stages.py"
click node_results "https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/stages.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_sketch,node_scene_data,node_user toneBlue
class node_method,node_methods,node_engine,node_attention,node_vision,node_config toneAmber
class node_matching,node_metrics,node_report toneMint
class node_runner,node_artifacts,node_stages,node_results toneRose
class node_external_data toneIndigo
```

## Components

### Scene input

- [Gradio interface](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/app.py): `ocsd/app.py`
- [Sketch and prompt parsing](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/sketch.py): `ocsd/sketch.py`
- [Benchmark scenes](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/data.py): `ocsd/data.py`

### Generation

- [OCSD preparation and generation](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/method.py): `ocsd/method.py`
- [Baseline methods](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/methods.py): `ocsd/methods.py`
- [Diffusion engine](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/engine.py): `ocsd/engine.py`
- [Attention control](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/attention.py): `ocsd/attention.py`
- [Vision models](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/vision.py): `ocsd/vision.py`
- [Generation configuration](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/config.py): `ocsd/config.py`

### Evaluation

- [Object consistency matching](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/matching.py): `ocsd/matching.py`
- [Image metrics](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/metrics.py): `ocsd/metrics.py`
- [Statistical reports](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/report.py): `ocsd/report.py`

### Experiments

- [Experiment runner](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/runner.py): `ocsd/runner.py`
- [Generated images and logs](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/runner.py): `ocsd/runner.py`
- [Experiment stages](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/stages.py): `ocsd/stages.py`
- [Experiment result files](https://github.com/bobbibao/ocsd-thesis/blob/main/ocsd/stages.py): `ocsd/stages.py`

### Other components

- **Sketch and text user**
- **QuickDraw and COCO**

## Connections

- Sketch and text user → Gradio interface: provides input
- Gradio interface → Sketch and prompt parsing: parses sketch
- Gradio interface → OCSD preparation and generation: prepares and generates
- Gradio interface → Vision models: checks detections
- Gradio interface → Object consistency matching: checks consistency
- QuickDraw and COCO → Benchmark scenes: provides samples
- Experiment stages → Benchmark scenes: builds benchmarks
- Experiment stages → Experiment runner: runs experiments
- Experiment stages → Image metrics: evaluates images
- Experiment stages → Statistical reports: builds reports
- Experiment runner → Benchmark scenes: loads scenes
- Experiment runner → OCSD preparation and generation: runs OCSD
- Experiment runner → Baseline methods: runs baselines
- Experiment runner → Generated images and logs: writes images and logs
- OCSD preparation and generation → Sketch and prompt parsing: uses scene prompts
- OCSD preparation and generation → Vision models: selects and checks objects
- OCSD preparation and generation → Diffusion engine: denoises and composes
- OCSD preparation and generation → Generation configuration: uses settings
- Diffusion engine → Attention control: uses processors
- Baseline methods → Diffusion engine: uses diffusion engine
- Image metrics → Generated images and logs: reads generated images
- Image metrics → Benchmark scenes: loads references
- Image metrics → Vision models: detects and scores
- Image metrics → Object consistency matching: computes consistency
- Image metrics → Experiment result files: writes per-image metrics
- Statistical reports → Experiment result files: reads metrics
- Statistical reports → Experiment result files: writes summaries and tables
- Experiment stages → Experiment result files: records experiment outputs
