# ahobe/rockoders_sem_image_assessment architecture

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

- Interactive diagram: https://gitdiagram.com/ahobe/rockoders_sem_image_assessment
- Repository: https://github.com/ahobe/rockoders_sem_image_assessment

## Overview

AssesSEM is a command-line workflow for segmenting minerals and pore spaces in SEM thin-section images and reporting their relative areas. Users choose datasets, model, predictor, and image count; the pipeline pairs BSE/CL images (optionally mineral-map images), predicts per-pixel classes, saves segmentation images, and writes CSV summaries. The graph includes the documented model and modality options; unsampled model files are represented by their listed directory, and edges are limited to visible imports/calls or README statements.

Main entry points: [`src/assesSEM/pipelines.py`](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/pipelines.py) (Prediction pipeline), [`src/assesSEM/IO.py`](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/IO.py) (Image and file I/O), [`src/assesSEM/model_manipulation.py`](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/model_manipulation.py) (Model loading), [`src/assesSEM/use_cases.py`](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/use_cases.py) (Image prediction use case)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Workflow and I/O"]
  node_runner["CLI runner<br/>[run.py]"]
  node_pipeline["Prediction pipeline<br/>[pipelines.py]"]
  node_input_options["Input selection<br/>[get_user_input.py]"]
  node_image_io["Image and file I/O<br/>[IO.py]"]
  node_microscopy["SEM image datasets"]
end

subgraph group_model["Model and prediction"]
  node_model_load["Model loading"]
  node_model_arch["U-Net and inputs<br/>[unet.py]"]
  node_weights[("Trained weights")]
  node_use_case["Image prediction use case<br/>[use_cases.py]"]
  node_predictors["Prediction strategies<br/>[predictors.py]"]
  node_smooth_tiles["Smooth tiled predictor"]
  node_slicing["Image slicing<br/>[slicing.py]"]
end

subgraph group_results["Segmentation results"]
  node_postprocess["Class and area processing<br/>[postprocessing.py]"]
  node_plotting["Segmentation rendering<br/>[plotting.py]"]
  node_segmented["Segmentation outputs"]
  node_csv["Area summary CSV"]
end

node_user(("Dataset user"))

node_user -->|"starts"| node_runner
node_runner -->|"runs"| node_pipeline
node_pipeline -->|"requests choices"| node_input_options
node_pipeline -->|"prepares and saves"| node_image_io
node_pipeline -->|"selects image files"| node_microscopy
node_pipeline -->|"loads model"| node_model_load
node_model_load -->|"builds model"| node_model_arch
node_model_load -->|"loads weights"| node_weights
node_pipeline -->|"requests predictions"| node_use_case
node_use_case -->|"builds model input"| node_model_arch
node_use_case -->|"dispatches prediction"| node_predictors
node_predictors -->|"uses tiled prediction"| node_smooth_tiles
node_predictors -->|"gets slice boxes"| node_slicing
node_pipeline -->|"converts and measures"| node_postprocess
node_pipeline -->|"saves predictions"| node_segmented
node_pipeline -->|"writes area summary"| node_csv
node_image_io -->|"checks output folder"| node_input_options
node_image_io -->|"gets color map"| node_plotting
node_model_arch -->|"reads and normalizes"| node_image_io

click node_runner "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/Data/run.py"
click node_pipeline "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/pipelines.py"
click node_input_options "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/get_user_input.py"
click node_image_io "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/IO.py"
click node_microscopy "https://github.com/ahobe/rockoders_sem_image_assessment/tree/main/Data"
click node_model_load "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/model_manipulation.py"
click node_model_arch "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/unet.py"
click node_weights "https://github.com/ahobe/rockoders_sem_image_assessment/tree/main/src/assesSEM/models"
click node_use_case "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/use_cases.py"
click node_predictors "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/predictors.py"
click node_smooth_tiles "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/smooth_tiled_predictions.py"
click node_slicing "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/predicting/slicing.py"
click node_postprocess "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/postprocessing.py"
click node_plotting "https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/plotting.py"
click node_segmented "https://github.com/ahobe/rockoders_sem_image_assessment/tree/main/Data/dataset1/CL_segmented"
click node_csv "https://github.com/ahobe/rockoders_sem_image_assessment/tree/main/Data/dataset1/CL_segmented"

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_runner,node_pipeline,node_input_options,node_image_io,node_microscopy,node_user toneBlue
class node_model_load,node_model_arch,node_weights,node_use_case,node_predictors,node_smooth_tiles,node_slicing toneAmber
class node_postprocess,node_plotting,node_segmented,node_csv toneMint
```

## Components

### Workflow and I/O

- [CLI runner](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/Data/run.py): `Data/run.py`
- [Prediction pipeline](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/pipelines.py): `src/assesSEM/pipelines.py`
- [Input selection](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/get_user_input.py): `src/assesSEM/get_user_input.py`
- [Image and file I/O](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/IO.py): `src/assesSEM/IO.py`
- [SEM image datasets](https://github.com/ahobe/rockoders_sem_image_assessment/tree/main/Data): `Data`

### Model and prediction

- [Model loading](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/model_manipulation.py): `src/assesSEM/model_manipulation.py`
- [U-Net and inputs](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/unet.py): `src/assesSEM/unet.py`
- [Trained weights](https://github.com/ahobe/rockoders_sem_image_assessment/tree/main/src/assesSEM/models): `src/assesSEM/models`
- [Image prediction use case](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/use_cases.py): `src/assesSEM/use_cases.py`
- [Prediction strategies](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/predictors.py): `src/assesSEM/predictors.py`
- [Smooth tiled predictor](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/smooth_tiled_predictions.py): `src/assesSEM/smooth_tiled_predictions.py`
- [Image slicing](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/predicting/slicing.py): `src/assesSEM/predicting/slicing.py`

### Segmentation results

- [Class and area processing](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/postprocessing.py): `src/assesSEM/postprocessing.py`
- [Segmentation rendering](https://github.com/ahobe/rockoders_sem_image_assessment/blob/main/src/assesSEM/plotting.py): `src/assesSEM/plotting.py`
- [Segmentation outputs](https://github.com/ahobe/rockoders_sem_image_assessment/tree/main/Data/dataset1/CL_segmented): `Data/dataset1/CL_segmented`
- [Area summary CSV](https://github.com/ahobe/rockoders_sem_image_assessment/tree/main/Data/dataset1/CL_segmented): `Data/dataset1/CL_segmented`

### Other components

- **Dataset user**

## Connections

- Dataset user → CLI runner: starts (evidence: `README.md`)
- CLI runner → Prediction pipeline: runs (evidence: `Data/run.py`)
- Prediction pipeline → Input selection: requests choices (evidence: `src/assesSEM/pipelines.py`)
- Prediction pipeline → Image and file I/O: prepares and saves (evidence: `src/assesSEM/pipelines.py`)
- Prediction pipeline → SEM image datasets: selects image files (evidence: `src/assesSEM/pipelines.py`)
- Prediction pipeline → Model loading: loads model (evidence: `src/assesSEM/pipelines.py`)
- Model loading → U-Net and inputs: builds model (evidence: `src/assesSEM/model_manipulation.py`)
- Model loading → Trained weights: loads weights (evidence: `README.md`)
- Prediction pipeline → Image prediction use case: requests predictions (evidence: `src/assesSEM/pipelines.py`)
- Image prediction use case → U-Net and inputs: builds model input (evidence: `src/assesSEM/use_cases.py`)
- Image prediction use case → Prediction strategies: dispatches prediction (evidence: `src/assesSEM/use_cases.py`)
- Prediction strategies → Smooth tiled predictor: uses tiled prediction (evidence: `src/assesSEM/predictors.py`)
- Prediction strategies → Image slicing: gets slice boxes (evidence: `src/assesSEM/predictors.py`)
- Prediction pipeline → Class and area processing: converts and measures (evidence: `src/assesSEM/pipelines.py`)
- Prediction pipeline → Segmentation outputs: saves predictions (evidence: `src/assesSEM/pipelines.py`)
- Prediction pipeline → Area summary CSV: writes area summary (evidence: `src/assesSEM/pipelines.py`)
- Image and file I/O → Input selection: checks output folder (evidence: `src/assesSEM/IO.py`)
- Image and file I/O → Segmentation rendering: gets color map (evidence: `src/assesSEM/IO.py`)
- U-Net and inputs → Image and file I/O: reads and normalizes (evidence: `src/assesSEM/unet.py`)
