# omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal architecture

> Architecture diagram of the GitHub repository omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal
- Repository: https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal

## Overview

##### Project type and purpose
- This is a machine-learning research pipeline focused on cloud removal in multispectral satellite images. It implements a hybrid Generative Adversarial Network (GAN) augmented with a Spectral Angular Distance (SAD) metric, plus pre- and post-processing steps (band stacking and polar coordinate transforms).

##### File structure
Top-level scripts and directories:
- Stacked12Bands.py – stacks 12 multispectral bands into composite images.
- images_2_Polar.m – MATLAB script converting stacked images into polar coordinates.
- PolarCoordinates_method_modified.py – Python-side polar transform and coordinate handling.
- stacked_tetas.py – assembles the polar-transformed bands back into training-ready patches.
- data_loader.py – data-loading utilities for Keras/TensorFlow.
- cyclegan_cloud.py – training driver that implements the hybrid GAN + SAD loss.
- Predict.py – inference script applying a trained model to test images.
- requirements.txt – lists Python dependencies (TensorFlow/Keras, NumPy, etc.).

##### README insights
- Workflow:
1. Stack raw multispectral data (Stacked12Bands.py)
2. Polar coordinate transform (MATLAB + Python scripts)
3. Assemble final training patches (stacked_tetas.py)
4. Train hybrid CycleGAN with SAD (cyclegan_cloud.py) via data_loader
5. Run inference on test data (Predict.py)
- Data organization: expects folders trainA, trainB (cloudy/clean), testA, testB.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Storage
    subgraph "Data Storage"
        direction TB
        RawData["Raw Multispectral Images\n(trainA, trainB, testA, testB)"]:::dataStorage
        ProcessedData["Processed Datasets\n(.npy stacks, polar images)"]:::dataStorage
    end

    %% Preprocessing Layer
    subgraph "Preprocessing" 
        direction TB
        BandStacking["Band Stacking Module\n(Stacked12Bands.py)"]:::preprocess
        MATLABPolar["Polar Conversion (MATLAB)\n(images_2_Polar.m)"]:::preprocess
        PyPolar["Polar Conversion (Python)\n(PolarCoordinates_method_modified.py)"]:::preprocess
        PatchAssembly["Patch Assembly Module\n(stacked_tetas.py)"]:::preprocess
    end

    %% Data Loader
    DataLoader["Data Loader Module\n(data_loader.py)"]:::preprocess

    %% Model Training
    subgraph "Model Training" 
        direction TB
        Training["Training Driver\n(cyclegan_cloud.py)"]:::training
        SADModule["Spectral Angular Distance Module"]:::training
        Checkpoint["Checkpoint & Logging"]:::training
        SavedModel["Saved Model\n(.h5, checkpoints)"]:::training
    end

    %% Inference
    subgraph "Model Inference & Output"
        direction TB
        Inference["Inference Script\n(Predict.py)"]:::inference
        Outputs["Cloud-Removed Images"]:::inference
    end

    %% External Dependencies
    subgraph "External Dependencies"
        direction TB
        MATLABEngine["MATLAB Engine API"]:::external
        PythonLibs["Python Libraries\n(TensorFlow/Keras, NumPy, etc.)"]:::external
        Requirements["requirements.txt"]:::external
        README["README.md"]:::external
    end

    %% Connections
    RawData -->|"stack raw data"| BandStacking
    BandStacking -->|"stacked_images.npy"| MATLABPolar
    MATLABPolar -->|"polar_images.mat"| PyPolar
    PyPolar -->|"polar_patches.npy"| PatchAssembly
    PatchAssembly -->|"training_patches"| DataLoader
    DataLoader -->|"batches"| Training
    Training -->|"model_weights"| SavedModel
    SavedModel -->|"trained_model"| Inference
    RawData -->|"test data"| Inference
    Inference -->|"predictions"| Outputs

    %% External Links
    MATLABEngine -.-> MATLABPolar
    PythonLibs -.-> DataLoader
    PythonLibs -.-> Training
    PythonLibs -.-> Inference

    %% Click Events
    click BandStacking "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/Stacked12Bands.py"
    click MATLABPolar "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/images_2_Polar.m"
    click PyPolar "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/PolarCoordinates_method_modified.py"
    click PatchAssembly "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/stacked_tetas.py"
    click DataLoader "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/data_loader.py"
    click Training "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/cyclegan_cloud.py"
    click Inference "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/Predict.py"
    click Requirements "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/requirements.txt"
    click README "https://github.com/omid-ghozatlou/hybrid-gan-and-spectral-angular-distance-for-cloud-removal/blob/main/README.md"

    %% Styles
    classDef dataStorage fill:#bbdefb,stroke:#1e88e5,color:#0d47a1;
    classDef preprocess fill:#c8e6c9,stroke:#43a047,color:#1b5e20;
    classDef training fill:#ffcdd2,stroke:#e53935,color:#b71c1c;
    classDef inference fill:#ffe0b2,stroke:#fb8c00,color:#e65100;
    classDef external fill:#f5f5f5,stroke:#9e9e9e,color:#616161,stroke-dasharray: 5 5;
```
