# dfilipeloja/breakhis architecture

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

- Interactive diagram: https://gitdiagram.com/dfilipeloja/breakhis
- Repository: https://github.com/dfilipeloja/breakhis

## Overview

This repository trains and evaluates binary classifiers for benign versus malignant breast histopathology images. The main workflow selects BreakHis images into training data, trains an AlexNet or pretrained VGG19 model, then loads a saved VGG19 model to classify test images and produce metrics and a confusion-matrix image. A separate demo script evaluates images arranged under a demo directory. The excerpts show training and evaluation code, but not the test-data injection script; its behavior and data flow are therefore not mapped.

Main entry points: [`train.py`](https://github.com/dfilipeloja/breakhis/blob/master/train.py) (Training workflow), [`predict.py`](https://github.com/dfilipeloja/breakhis/blob/master/predict.py) (Test prediction), [`generate-dataset.py`](https://github.com/dfilipeloja/breakhis/blob/master/generate-dataset.py) (Dataset selection), [`models`](https://github.com/dfilipeloja/breakhis/tree/master/models) (Saved models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Image data"]
  node_breakhis[("BreakHis dataset")]
  node_dataset_prep["Dataset selection"]
  node_train_images[("Training images")]
  node_test_images[("Test images")]
  node_demo_images[("Demo images")]
end

subgraph group_training["Model training"]
  node_trainer["Training workflow<br/>[train.py]"]
  node_architectures["Model architectures<br/>[models.py]"]
  node_model_store[("Saved models")]
end

subgraph group_inference["Prediction and evaluation"]
  node_predictor["Test prediction<br/>[predict.py]"]
  node_demo_evaluation["Demo evaluation<br/>[demo.py]"]
end

subgraph group_outputs["Results"]
  node_classification_results["Classification reports"]
  node_prediction_graphs["Confusion matrices"]
  node_training_graphs["Training graphs<br/>[graphs.py]"]
end

node_user(("Dataset user"))

node_user -->|"obtains"| node_breakhis
node_user -->|"runs"| node_dataset_prep
node_breakhis -->|"selects images"| node_dataset_prep
node_dataset_prep -->|"copies images"| node_train_images
node_user -->|"runs"| node_trainer
node_trainer -->|"loads batches"| node_train_images
node_trainer -->|"loads validation batches"| node_test_images
node_trainer -->|"creates model"| node_architectures
node_trainer -->|"saves AlexNet"| node_model_store
node_trainer -->|"plots training"| node_training_graphs
node_user -->|"runs"| node_predictor
node_predictor -->|"loads VGG19"| node_model_store
node_predictor -->|"classifies"| node_test_images
node_predictor -->|"writes report"| node_classification_results
node_predictor -->|"writes matrix"| node_prediction_graphs
node_demo_evaluation -->|"loads VGG19"| node_model_store
node_demo_evaluation -->|"classifies"| node_demo_images

click node_dataset_prep "https://github.com/dfilipeloja/breakhis/blob/master/generate-dataset.py"
click node_train_images "https://github.com/dfilipeloja/breakhis/tree/master/train"
click node_test_images "https://github.com/dfilipeloja/breakhis/tree/master/test"
click node_trainer "https://github.com/dfilipeloja/breakhis/blob/master/train.py"
click node_architectures "https://github.com/dfilipeloja/breakhis/blob/master/models.py"
click node_model_store "https://github.com/dfilipeloja/breakhis/tree/master/models"
click node_predictor "https://github.com/dfilipeloja/breakhis/blob/master/predict.py"
click node_demo_evaluation "https://github.com/dfilipeloja/breakhis/blob/master/demo.py"
click node_demo_images "https://github.com/dfilipeloja/breakhis/tree/master/demo"
click node_classification_results "https://github.com/dfilipeloja/breakhis/tree/master/results/classification_reports"
click node_prediction_graphs "https://github.com/dfilipeloja/breakhis/tree/master/results"
click node_training_graphs "https://github.com/dfilipeloja/breakhis/blob/master/graphs.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_breakhis,node_dataset_prep,node_train_images,node_test_images,node_demo_images,node_user toneBlue
class node_trainer,node_architectures,node_model_store toneAmber
class node_predictor,node_demo_evaluation toneMint
class node_classification_results,node_prediction_graphs,node_training_graphs toneRose
```

## Components

### Image data

- **BreakHis dataset**
- [Dataset selection](https://github.com/dfilipeloja/breakhis/blob/master/generate-dataset.py): `generate-dataset.py`
- [Training images](https://github.com/dfilipeloja/breakhis/tree/master/train): `train`
- [Test images](https://github.com/dfilipeloja/breakhis/tree/master/test): `test`
- [Demo images](https://github.com/dfilipeloja/breakhis/tree/master/demo): `demo`

### Model training

- [Training workflow](https://github.com/dfilipeloja/breakhis/blob/master/train.py): `train.py`
- [Model architectures](https://github.com/dfilipeloja/breakhis/blob/master/models.py): `models.py`
- [Saved models](https://github.com/dfilipeloja/breakhis/tree/master/models): `models`

### Prediction and evaluation

- [Test prediction](https://github.com/dfilipeloja/breakhis/blob/master/predict.py): `predict.py`
- [Demo evaluation](https://github.com/dfilipeloja/breakhis/blob/master/demo.py): `demo.py`

### Results

- [Classification reports](https://github.com/dfilipeloja/breakhis/tree/master/results/classification_reports): `results/classification_reports`
- [Confusion matrices](https://github.com/dfilipeloja/breakhis/tree/master/results): `results`
- [Training graphs](https://github.com/dfilipeloja/breakhis/blob/master/graphs.py): `graphs.py`

### Other components

- **Dataset user**

## Connections

- Dataset user → BreakHis dataset: obtains (evidence: `README.md`)
- Dataset user → Dataset selection: runs (evidence: `README.md`)
- BreakHis dataset → Dataset selection: selects images (evidence: `generate-dataset.py`)
- Dataset selection → Training images: copies images (evidence: `generate-dataset.py`)
- Dataset user → Training workflow: runs (evidence: `README.md`)
- Training workflow → Training images: loads batches (evidence: `train.py`)
- Training workflow → Test images: loads validation batches (evidence: `train.py`)
- Training workflow → Model architectures: creates model (evidence: `train.py`)
- Training workflow → Saved models: saves AlexNet (evidence: `train.py`)
- Training workflow → Training graphs: plots training (evidence: `train.py`)
- Dataset user → Test prediction: runs (evidence: `README.md`)
- Test prediction → Saved models: loads VGG19 (evidence: `predict.py`)
- Test prediction → Test images: classifies (evidence: `predict.py`)
- Test prediction → Classification reports: writes report (evidence: `predict.py`)
- Test prediction → Confusion matrices: writes matrix (evidence: `predict.py`)
- Demo evaluation → Saved models: loads VGG19 (evidence: `demo.py`)
- Demo evaluation → Demo images: classifies (evidence: `demo.py`)
