# bhar07gavi/cloud_removal architecture

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

- Interactive diagram: https://gitdiagram.com/bhar07gavi/cloud_removal
- Repository: https://github.com/bhar07gavi/cloud_removal

## Overview

The repository implements paired-image preprocessing, pix2pix GAN training and evaluation, experiment tracking, and a local Gradio inference demo for satellite cloud removal. The main workflow prepares RICE image pairs into patches and splits, trains a generator against a PatchGAN discriminator, evaluates saved weights, and serves cloud-removal predictions. README claims are supplemented with the sampled evaluation and tuning implementations; wiring not shown in excerpts is omitted.

Main entry points: [`src/training/train.py`](https://github.com/bhar07gavi/cloud_removal/blob/main/src/training/train.py) (GAN training loop), [`src/models/eval.py`](https://github.com/bhar07gavi/cloud_removal/blob/main/src/models/eval.py) (Test-set evaluation), [`serving/inference.py`](https://github.com/bhar07gavi/cloud_removal/blob/main/serving/inference.py) (Inference pipeline), [`src/data/preprocess.py`](https://github.com/bhar07gavi/cloud_removal/blob/main/src/data/preprocess.py) (Patch preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_preprocess["Patch preprocessing<br/>[preprocess.py]"]
  node_patches_splits["Patches and splits"]
  node_dataset["Paired patch loader<br/>[dataset.py]"]
end

subgraph group_model["GAN training"]
  node_train["GAN training loop<br/>[train.py]"]
  node_generator["U-Net generator<br/>[generator.py]"]
  node_discriminator["PatchGAN discriminator<br/>[discriminator.py]"]
  node_losses["GAN and L1 losses<br/>[losses.py]"]
  node_checkpoints["Model checkpoints"]
end

subgraph group_assessment["Evaluation and tuning"]
  node_tracking["MLflow tracking"]
  node_evaluate["Test-set evaluation<br/>[eval.py]"]
  node_tune["Hyperparameter sweep<br/>[tune.py]"]
end

subgraph group_serving["Interactive serving"]
  node_demo["Gradio interface<br/>[demo_app.py]"]
  node_inference["Inference pipeline<br/>[inference.py]"]
end

node_data_user(("Dataset operator"))
node_raw_rice["RICE image pairs"]
node_train_user(("ML engineer"))
node_mlflow_service["DAGsHub MLflow"]
node_demo_user(("Demo user"))

node_data_user -->|"starts preprocessing"| node_preprocess
node_raw_rice -->|"reads pairs"| node_preprocess
node_preprocess -->|"writes patches and splits"| node_patches_splits
node_patches_splits -->|"provides split files"| node_dataset
node_dataset -->|"provides paired batches"| node_train
node_train_user -->|"starts training"| node_train
node_train -->|"updates generator"| node_generator
node_train -->|"updates discriminator"| node_discriminator
node_train -->|"computes objectives"| node_losses
node_train -->|"saves best weights"| node_checkpoints
node_train -->|"logs metrics and artifacts"| node_tracking
node_tracking -.->|"records experiment"| node_mlflow_service
node_evaluate -->|"loads test patches"| node_dataset
node_evaluate -->|"loads generator weights"| node_checkpoints
node_evaluate -->|"runs predictions"| node_generator
node_evaluate -->|"logs evaluation metrics"| node_tracking
node_tune -->|"runs trial training"| node_train
node_tune -->|"logs sweep runs"| node_tracking
node_demo_user -->|"uploads image"| node_demo
node_demo -->|"requests prediction"| node_inference
node_inference -->|"loads weights"| node_checkpoints
node_inference -->|"generates reconstruction"| node_generator
node_inference -->|"returns image"| node_demo

click node_preprocess "https://github.com/bhar07gavi/cloud_removal/blob/main/src/data/preprocess.py"
click node_dataset "https://github.com/bhar07gavi/cloud_removal/blob/main/src/data/dataset.py"
click node_train "https://github.com/bhar07gavi/cloud_removal/blob/main/src/training/train.py"
click node_generator "https://github.com/bhar07gavi/cloud_removal/blob/main/src/models/generator.py"
click node_discriminator "https://github.com/bhar07gavi/cloud_removal/blob/main/src/models/discriminator.py"
click node_losses "https://github.com/bhar07gavi/cloud_removal/blob/main/src/training/losses.py"
click node_evaluate "https://github.com/bhar07gavi/cloud_removal/blob/main/src/models/eval.py"
click node_tune "https://github.com/bhar07gavi/cloud_removal/blob/main/src/training/tune.py"
click node_demo "https://github.com/bhar07gavi/cloud_removal/blob/main/serving/demo_app.py"
click node_inference "https://github.com/bhar07gavi/cloud_removal/blob/main/serving/inference.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_preprocess,node_patches_splits,node_dataset,node_demo_user toneBlue
class node_train,node_generator,node_discriminator,node_losses,node_checkpoints toneAmber
class node_tracking,node_evaluate,node_tune toneMint
class node_demo,node_inference toneRose
class node_data_user,node_raw_rice,node_train_user,node_mlflow_service toneIndigo
```

## Components

### Data preparation

- [Patch preprocessing](https://github.com/bhar07gavi/cloud_removal/blob/main/src/data/preprocess.py): `src/data/preprocess.py`
- **Patches and splits**
- [Paired patch loader](https://github.com/bhar07gavi/cloud_removal/blob/main/src/data/dataset.py): `src/data/dataset.py`

### GAN training

- [GAN training loop](https://github.com/bhar07gavi/cloud_removal/blob/main/src/training/train.py): `src/training/train.py`
- [U-Net generator](https://github.com/bhar07gavi/cloud_removal/blob/main/src/models/generator.py): `src/models/generator.py`
- [PatchGAN discriminator](https://github.com/bhar07gavi/cloud_removal/blob/main/src/models/discriminator.py): `src/models/discriminator.py`
- [GAN and L1 losses](https://github.com/bhar07gavi/cloud_removal/blob/main/src/training/losses.py): `src/training/losses.py`
- **Model checkpoints**

### Evaluation and tuning

- **MLflow tracking**
- [Test-set evaluation](https://github.com/bhar07gavi/cloud_removal/blob/main/src/models/eval.py): `src/models/eval.py`
- [Hyperparameter sweep](https://github.com/bhar07gavi/cloud_removal/blob/main/src/training/tune.py): `src/training/tune.py`

### Interactive serving

- [Gradio interface](https://github.com/bhar07gavi/cloud_removal/blob/main/serving/demo_app.py): `serving/demo_app.py`
- [Inference pipeline](https://github.com/bhar07gavi/cloud_removal/blob/main/serving/inference.py): `serving/inference.py`

### Other components

- **Dataset operator**
- **RICE image pairs**
- **ML engineer**
- **DAGsHub MLflow**
- **Demo user**

## Connections

- Dataset operator → Patch preprocessing: starts preprocessing
- RICE image pairs → Patch preprocessing: reads pairs
- Patch preprocessing → Patches and splits: writes patches and splits
- Patches and splits → Paired patch loader: provides split files
- Paired patch loader → GAN training loop: provides paired batches
- ML engineer → GAN training loop: starts training
- GAN training loop → U-Net generator: updates generator
- GAN training loop → PatchGAN discriminator: updates discriminator
- GAN training loop → GAN and L1 losses: computes objectives
- GAN training loop → Model checkpoints: saves best weights
- GAN training loop → MLflow tracking: logs metrics and artifacts
- MLflow tracking → DAGsHub MLflow: records experiment
- Test-set evaluation → Paired patch loader: loads test patches
- Test-set evaluation → Model checkpoints: loads generator weights
- Test-set evaluation → U-Net generator: runs predictions
- Test-set evaluation → MLflow tracking: logs evaluation metrics
- Hyperparameter sweep → GAN training loop: runs trial training
- Hyperparameter sweep → MLflow tracking: logs sweep runs
- Demo user → Gradio interface: uploads image
- Gradio interface → Inference pipeline: requests prediction
- Inference pipeline → Model checkpoints: loads weights
- Inference pipeline → U-Net generator: generates reconstruction
- Inference pipeline → Gradio interface: returns image
