# afshazareen/oil_spill_segmentation architecture

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

- Interactive diagram: https://gitdiagram.com/afshazareen/oil_spill_segmentation
- Repository: https://github.com/afshazareen/oil_spill_segmentation

## Overview

This is a Flask oil-spill image segmentation web app. A user submits an image; the Flask route saves it and invokes inference, which preprocesses the image, runs the U-Net, and generates a binary mask and red overlay. The route then returns the configured output file to the browser. In the shown call, that file is saved as the mask path, so the response is the mask rather than the separately generated overlay described by the README. The source excerpts establish the main runtime links; template-side behavior beyond the README is not inspected.

Main entry points: [`inference.py`](https://github.com/afshazareen/oil_spill_segmentation/blob/main/inference.py) (Inference pipeline), [`app.py`](https://github.com/afshazareen/oil_spill_segmentation/blob/main/app.py) (Flask routes), [`templates/index.html`](https://github.com/afshazareen/oil_spill_segmentation/blob/main/templates/index.html) (Upload page), [`static`](https://github.com/afshazareen/oil_spill_segmentation/tree/main/static) (Static output)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_index["Upload page<br/>[index.html]"]
end

subgraph group_runtime["Request runtime"]
  node_flask["Flask routes<br/>[app.py]"]
end

subgraph group_inference["Segmentation inference"]
  node_pipeline["Inference pipeline<br/>[inference.py]"]
  node_architecture["U-Net architecture<br/>[model_arch.py]"]
  node_weights[("Trained weights<br/>[model.pth]")]
end

subgraph group_artifacts["Image artifacts"]
  node_uploads[("Uploaded images")]
  node_mask["Binary mask<br/>[inference.py]"]
  node_overlay["Red overlay<br/>[inference.py]"]
  node_static[("Static output")]
end

node_user(("Image uploader"))

node_user -->|"uploads image"| node_index
node_index -->|"submits image"| node_flask
node_flask -->|"renders page"| node_index
node_flask -->|"saves upload"| node_uploads
node_flask -->|"runs inference"| node_pipeline
node_pipeline -->|"loads model"| node_architecture
node_pipeline -->|"loads weights"| node_weights
node_pipeline -->|"creates mask"| node_mask
node_pipeline -->|"blends overlay"| node_overlay
node_pipeline -->|"saves outputs"| node_static
node_flask -->|"sends output"| node_static
node_static -->|"returns image"| node_user

click node_index "https://github.com/afshazareen/oil_spill_segmentation/blob/main/templates/index.html"
click node_flask "https://github.com/afshazareen/oil_spill_segmentation/blob/main/app.py"
click node_uploads "https://github.com/afshazareen/oil_spill_segmentation/tree/main/uploads"
click node_pipeline "https://github.com/afshazareen/oil_spill_segmentation/blob/main/inference.py"
click node_architecture "https://github.com/afshazareen/oil_spill_segmentation/blob/main/model_arch.py"
click node_weights "https://github.com/afshazareen/oil_spill_segmentation/blob/main/model.pth"
click node_mask "https://github.com/afshazareen/oil_spill_segmentation/blob/main/inference.py"
click node_overlay "https://github.com/afshazareen/oil_spill_segmentation/blob/main/inference.py"
click node_static "https://github.com/afshazareen/oil_spill_segmentation/tree/main/static"

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_index toneBlue
class node_flask toneAmber
class node_pipeline,node_architecture,node_weights toneMint
class node_uploads,node_mask,node_overlay,node_static toneRose
class node_user toneIndigo
```

## Components

### Web interface

- [Upload page](https://github.com/afshazareen/oil_spill_segmentation/blob/main/templates/index.html): `templates/index.html`

### Request runtime

- [Flask routes](https://github.com/afshazareen/oil_spill_segmentation/blob/main/app.py): `app.py`

### Segmentation inference

- [Inference pipeline](https://github.com/afshazareen/oil_spill_segmentation/blob/main/inference.py): `inference.py`
- [U-Net architecture](https://github.com/afshazareen/oil_spill_segmentation/blob/main/model_arch.py): `model_arch.py`
- [Trained weights](https://github.com/afshazareen/oil_spill_segmentation/blob/main/model.pth): `model.pth`

### Image artifacts

- [Uploaded images](https://github.com/afshazareen/oil_spill_segmentation/tree/main/uploads): `uploads`
- [Binary mask](https://github.com/afshazareen/oil_spill_segmentation/blob/main/inference.py): `inference.py`
- [Red overlay](https://github.com/afshazareen/oil_spill_segmentation/blob/main/inference.py): `inference.py`
- [Static output](https://github.com/afshazareen/oil_spill_segmentation/tree/main/static): `static`

### Other components

- **Image uploader**

## Connections

- Image uploader → Upload page: uploads image (evidence: `README.md`)
- Upload page → Flask routes: submits image (evidence: `README.md`)
- Flask routes → Upload page: renders page (evidence: `app.py`)
- Flask routes → Uploaded images: saves upload (evidence: `app.py`)
- Flask routes → Inference pipeline: runs inference (evidence: `app.py`)
- Inference pipeline → U-Net architecture: loads model (evidence: `inference.py`)
- Inference pipeline → Trained weights: loads weights (evidence: `inference.py`)
- Inference pipeline → Binary mask: creates mask (evidence: `inference.py`)
- Inference pipeline → Red overlay: blends overlay (evidence: `inference.py`)
- Inference pipeline → Static output: saves outputs (evidence: `inference.py`)
- Flask routes → Static output: sends output (evidence: `app.py`)
- Static output → Image uploader: returns image
