# jfayyad/lesiongen architecture

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

- Interactive diagram: https://gitdiagram.com/jfayyad/lesiongen
- Repository: https://github.com/jfayyad/lesiongen

## Overview

LesionGen trains a concept-guided diffusion model on dermatology image–caption data, generates conditioned lesion images, and evaluates classification performance on real or synthetic datasets. The README documents both LoRA and full-model training, while the sampled generator loads a pretrained Stable Diffusion pipeline and LoRA weights. Classification training uses a data-loading module; separate evaluation scripts assess generated or test images. Training-script internals and the referenced test loader were not sampled, so their relationships are shown only where the README or source index supports them.

Main entry points: [`generate.py`](https://github.com/jfayyad/lesiongen/blob/main/generate.py) (Conditioned generation), [`train_lora.sh`](https://github.com/jfayyad/lesiongen/blob/main/train_lora.sh) (LoRA training), [`train_SD.sh`](https://github.com/jfayyad/lesiongen/blob/main/train_SD.sh) (Full-model training), [`classification/eval_synth.py`](https://github.com/jfayyad/lesiongen/blob/main/classification/eval_synth.py) (Synthetic evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Dermatology data"]
  node_derm_datasets[("HAM10000 / D7P")]
  node_concept_captions["Concept-rich captions"]
  node_synthetic_images[("Synthetic images")]
end

subgraph group_diffusion["Image synthesis"]
  node_lora_train["LoRA training<br/>[train_lora.sh]"]
  node_full_train["Full-model training<br/>[train_SD.sh]"]
  node_diffusion_model["Trained diffusion model<br/>[train_lora.sh]"]
  node_image_generation["Conditioned generation<br/>[generate.py]"]
  node_base_model["Stable Diffusion"]
end

subgraph group_classification["Classification"]
  node_classification_data["Dataset loading<br/>[dataloader.py]"]
  node_classifier_training["Classifier training<br/>[classifier.py]"]
  node_classifier_weights[("Classifier weights")]
end

subgraph group_evaluation["Evaluation"]
  node_synthetic_eval["Synthetic evaluation<br/>[eval_synth.py]"]
  node_prediction_eval["Prediction evaluation<br/>[eval_with_pred.py]"]
  node_generated_eval["Generated-image evaluation<br/>[eval.py]"]
  node_test_loader["Evaluation data loader<br/>[test_loader.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"starts training"| node_lora_train
node_researcher -->|"starts training"| node_full_train
node_derm_datasets -->|"paired with captions"| node_concept_captions
node_concept_captions -->|"trains on pairs"| node_lora_train
node_concept_captions -->|"trains on pairs"| node_full_train
node_lora_train -->|"fine-tunes model"| node_diffusion_model
node_full_train -->|"fine-tunes model"| node_diffusion_model
node_researcher -->|"provides condition"| node_image_generation
node_image_generation -->|"loads pipeline"| node_base_model
node_image_generation -->|"loads LoRA weights"| node_diffusion_model
node_image_generation -->|"writes images"| node_synthetic_images
node_derm_datasets -->|"loads image data"| node_classification_data
node_classification_data -->|"provides batches"| node_classifier_training
node_classifier_training -->|"saves weights"| node_classifier_weights
node_synthetic_images -->|"evaluated as input"| node_synthetic_eval
node_test_loader -->|"provides batches"| node_synthetic_eval
node_classifier_weights -->|"loads weights"| node_synthetic_eval
node_test_loader -->|"provides batches"| node_prediction_eval
node_classifier_weights -->|"loads weights"| node_prediction_eval
node_synthetic_images -->|"evaluated as input"| node_generated_eval
node_classifier_weights -->|"loads weights"| node_generated_eval

click node_lora_train "https://github.com/jfayyad/lesiongen/blob/main/train_lora.sh"
click node_full_train "https://github.com/jfayyad/lesiongen/blob/main/train_SD.sh"
click node_diffusion_model "https://github.com/jfayyad/lesiongen/blob/main/train_lora.sh"
click node_image_generation "https://github.com/jfayyad/lesiongen/blob/main/generate.py"
click node_classification_data "https://github.com/jfayyad/lesiongen/blob/main/classification/dataloader.py"
click node_classifier_training "https://github.com/jfayyad/lesiongen/blob/main/classification/classifier.py"
click node_synthetic_eval "https://github.com/jfayyad/lesiongen/blob/main/classification/eval_synth.py"
click node_prediction_eval "https://github.com/jfayyad/lesiongen/blob/main/classification/eval_with_pred.py"
click node_generated_eval "https://github.com/jfayyad/lesiongen/blob/main/classification/eval.py"
click node_test_loader "https://github.com/jfayyad/lesiongen/blob/main/classification/test_loader.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_derm_datasets,node_concept_captions,node_synthetic_images toneBlue
class node_lora_train,node_full_train,node_diffusion_model,node_image_generation,node_base_model toneAmber
class node_classification_data,node_classifier_training,node_classifier_weights toneMint
class node_synthetic_eval,node_prediction_eval,node_generated_eval,node_test_loader toneRose
class node_researcher toneIndigo
```

## Components

### Dermatology data

- **HAM10000 / D7P**
- **Concept-rich captions**
- **Synthetic images**

### Image synthesis

- [LoRA training](https://github.com/jfayyad/lesiongen/blob/main/train_lora.sh): `train_lora.sh`
- [Full-model training](https://github.com/jfayyad/lesiongen/blob/main/train_SD.sh): `train_SD.sh`
- [Trained diffusion model](https://github.com/jfayyad/lesiongen/blob/main/train_lora.sh): `train_lora.sh`
- [Conditioned generation](https://github.com/jfayyad/lesiongen/blob/main/generate.py): `generate.py`
- **Stable Diffusion**

### Classification

- [Dataset loading](https://github.com/jfayyad/lesiongen/blob/main/classification/dataloader.py): `classification/dataloader.py`
- [Classifier training](https://github.com/jfayyad/lesiongen/blob/main/classification/classifier.py): `classification/classifier.py`
- **Classifier weights**

### Evaluation

- [Synthetic evaluation](https://github.com/jfayyad/lesiongen/blob/main/classification/eval_synth.py): `classification/eval_synth.py`
- [Prediction evaluation](https://github.com/jfayyad/lesiongen/blob/main/classification/eval_with_pred.py): `classification/eval_with_pred.py`
- [Generated-image evaluation](https://github.com/jfayyad/lesiongen/blob/main/classification/eval.py): `classification/eval.py`
- [Evaluation data loader](https://github.com/jfayyad/lesiongen/blob/main/classification/test_loader.py): `classification/test_loader.py`

### Other components

- **Researcher**

## Connections

- Researcher → LoRA training: starts training (evidence: `README.md`)
- Researcher → Full-model training: starts training (evidence: `README.md`)
- HAM10000 / D7P → Concept-rich captions: paired with captions (evidence: `README.md`)
- Concept-rich captions → LoRA training: trains on pairs (evidence: `README.md`)
- Concept-rich captions → Full-model training: trains on pairs (evidence: `README.md`)
- LoRA training → Trained diffusion model: fine-tunes model (evidence: `README.md`)
- Full-model training → Trained diffusion model: fine-tunes model (evidence: `README.md`)
- Researcher → Conditioned generation: provides condition (evidence: `README.md`)
- Conditioned generation → Stable Diffusion: loads pipeline (evidence: `generate.py`)
- Conditioned generation → Trained diffusion model: loads LoRA weights (evidence: `generate.py`)
- Conditioned generation → Synthetic images: writes images (evidence: `generate.py`)
- HAM10000 / D7P → Dataset loading: loads image data (evidence: `classification/dataloader.py`)
- Dataset loading → Classifier training: provides batches (evidence: `classification/classifier.py`)
- Classifier training → Classifier weights: saves weights (evidence: `classification/classifier.py`)
- Synthetic images → Synthetic evaluation: evaluated as input (evidence: `README.md`)
- Evaluation data loader → Synthetic evaluation: provides batches (evidence: `classification/eval_synth.py`)
- Classifier weights → Synthetic evaluation: loads weights (evidence: `classification/eval_synth.py`)
- Evaluation data loader → Prediction evaluation: provides batches (evidence: `classification/eval_with_pred.py`)
- Classifier weights → Prediction evaluation: loads weights (evidence: `classification/eval_with_pred.py`)
- Synthetic images → Generated-image evaluation: evaluated as input (evidence: `classification/eval.py`)
- Classifier weights → Generated-image evaluation: loads weights (evidence: `classification/eval.py`)
