# mikehms/cm3070-final-year-project architecture

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

- Interactive diagram: https://gitdiagram.com/mikehms/cm3070-final-year-project
- Repository: https://github.com/mikehms/cm3070-final-year-project

## Overview

This repository implements optimisation-based neural style transfer (NST), exposed through a command-line image workflow and extended with video stylisation and experiment evaluation. The primary path loads content and style images, extracts VGG features, optimises a generated image against content/style/regularisation losses, then saves the image and evaluation outputs. Colour preservation and multi-style blending are supported inside the engine. The README documents the experiment runner and video capability; their internal wiring is not fully shown in the sampled source, so those links are marked unverified.

Main entry points: [`run_nst.py`](https://github.com/mikehms/cm3070-final-year-project/blob/main/run_nst.py) (Image CLI), [`nst/core.py`](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/core.py) (Optimisation Engine), [`nst/metrics.py`](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/metrics.py) (Image Metrics), [`nst/models.py`](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/models.py) (VGG Features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interfaces"]
  node_cli["Image CLI<br/>[run_nst.py]"]
  node_image_io["Image I/O<br/>[io.py]"]
end

subgraph group_engine["NST Engine"]
  node_engine["Optimisation Engine<br/>[core.py]"]
  node_vgg["VGG Features<br/>[models.py]"]
  node_losses["NST Losses<br/>[losses.py]"]
  node_colour["Colour Preservation<br/>[colour.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_metrics["Image Metrics<br/>[metrics.py]"]
end

subgraph group_experiments["Experiments"]
  node_video["Video NST<br/>[video_nst.py]"]
  node_runner["Experiment Runner<br/>[run_experiments.py]"]
  node_figures["Report Figures<br/>[make_figures.py]"]
end

node_user(("User"))
node_output["Image and Metrics"]

node_user -->|"configures"| node_cli
node_cli -->|"loads inputs"| node_image_io
node_cli -->|"runs stylisation"| node_engine
node_engine -->|"extracts features"| node_vgg
node_engine -->|"computes losses"| node_losses
node_engine -->|"preserves colour"| node_colour
node_vgg -->|"loads calibration images"| node_image_io
node_cli -->|"saves output"| node_image_io
node_cli -->|"evaluates result"| node_metrics
node_cli -->|"writes image and reports"| node_output
node_video -->|"stylises frames"| node_engine
node_video -->|"scores frames"| node_metrics
node_metrics -->|"computes Gram matrices"| node_losses
node_metrics -->|"uses evaluator network"| node_vgg
node_runner -.->|"runs experiments"| node_engine
node_runner -.->|"records metrics"| node_metrics
node_figures -->|"summarises evaluations"| node_metrics

click node_cli "https://github.com/mikehms/cm3070-final-year-project/blob/main/run_nst.py"
click node_image_io "https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/io.py"
click node_engine "https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/core.py"
click node_vgg "https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/models.py"
click node_losses "https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/losses.py"
click node_colour "https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/colour.py"
click node_metrics "https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/metrics.py"
click node_video "https://github.com/mikehms/cm3070-final-year-project/blob/main/experiments/video_nst.py"
click node_runner "https://github.com/mikehms/cm3070-final-year-project/blob/main/experiments/run_experiments.py"
click node_figures "https://github.com/mikehms/cm3070-final-year-project/blob/main/experiments/make_figures.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_cli,node_image_io,node_user toneBlue
class node_engine,node_vgg,node_losses,node_colour toneAmber
class node_metrics toneMint
class node_video,node_runner,node_figures toneRose
class node_output toneIndigo
```

## Components

### User Interfaces

- [Image CLI](https://github.com/mikehms/cm3070-final-year-project/blob/main/run_nst.py): `run_nst.py`
- [Image I/O](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/io.py): `nst/io.py`

### NST Engine

- [Optimisation Engine](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/core.py): `nst/core.py`
- [VGG Features](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/models.py): `nst/models.py`
- [NST Losses](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/losses.py): `nst/losses.py`
- [Colour Preservation](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/colour.py): `nst/colour.py`

### Evaluation

- [Image Metrics](https://github.com/mikehms/cm3070-final-year-project/blob/main/nst/metrics.py): `nst/metrics.py`

### Experiments

- [Video NST](https://github.com/mikehms/cm3070-final-year-project/blob/main/experiments/video_nst.py): `experiments/video_nst.py`
- [Experiment Runner](https://github.com/mikehms/cm3070-final-year-project/blob/main/experiments/run_experiments.py): `experiments/run_experiments.py`
- [Report Figures](https://github.com/mikehms/cm3070-final-year-project/blob/main/experiments/make_figures.py): `experiments/make_figures.py`

### Other components

- **User**
- **Image and Metrics**

## Connections

- User → Image CLI: configures (evidence: `run_nst.py`)
- Image CLI → Image I/O: loads inputs (evidence: `run_nst.py`)
- Image CLI → Optimisation Engine: runs stylisation (evidence: `run_nst.py`)
- Optimisation Engine → VGG Features: extracts features (evidence: `nst/core.py`)
- Optimisation Engine → NST Losses: computes losses (evidence: `nst/core.py`)
- Optimisation Engine → Colour Preservation: preserves colour (evidence: `nst/core.py`)
- VGG Features → Image I/O: loads calibration images (evidence: `nst/models.py`)
- Image CLI → Image I/O: saves output (evidence: `run_nst.py`)
- Image CLI → Image Metrics: evaluates result (evidence: `run_nst.py`)
- Image CLI → Image and Metrics: writes image and reports (evidence: `run_nst.py`)
- Video NST → Optimisation Engine: stylises frames (evidence: `experiments/video_nst.py`)
- Video NST → Image Metrics: scores frames (evidence: `experiments/video_nst.py`)
- Image Metrics → NST Losses: computes Gram matrices (evidence: `nst/metrics.py`)
- Image Metrics → VGG Features: uses evaluator network (evidence: `nst/metrics.py`)
- Experiment Runner → Optimisation Engine: runs experiments (evidence: `README.md`)
- Experiment Runner → Image Metrics: records metrics (evidence: `README.md`)
- Report Figures → Image Metrics: summarises evaluations (evidence: `experiments/make_figures.py`)
