# nandhakishorm/image-background-remove-tool architecture

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

- Interactive diagram: https://gitdiagram.com/nandhakishorm/image-background-remove-tool
- Repository: https://github.com/nandhakishorm/image-background-remove-tool

## Overview

Image Background Remove Tool accepts an image file or folder through a CLI or GUI, selects a segmentation model and optional preprocessing/postprocessing methods, then saves transparent PNG results. Its main runtime layers are the interfaces, orchestration, image-processing methods, and neural-network implementations. The README documents additional model and method capabilities not fully shown in the sampled excerpts; those are represented without asserting unsampled internal call paths.

Main entry points: [`main.py`](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/main.py) (Image workflow), [`libs/networks.py`](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py) (Model selection), [`libs/preprocessing.py`](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/preprocessing.py) (Object preprocessing), [`libs/postprocessing.py`](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/postprocessing.py) (Boundary refinement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[main.py]"]
  node_gui["GUI<br/>[gui.py]"]
  node_web_ui["GUI page<br/>[index.html]"]
end

subgraph group_processing["Image processing"]
  node_orchestrator["Image workflow<br/>[main.py]"]
  node_preprocess["Object preprocessing<br/>[preprocessing.py]"]
  node_postprocess["Boundary refinement<br/>[postprocessing.py]"]
  node_methods["Method names<br/>[strings.py]"]
end

subgraph group_models["Segmentation models"]
  node_model_select["Model selection<br/>[networks.py]"]
  node_u2_adapter["U2Net adapter<br/>[networks.py]"]
  node_bas_adapter["BASNet adapter<br/>[networks.py]"]
  node_tf_adapter["DeepLab adapter<br/>[networks.py]"]
end

subgraph group_network_impl["Network implementations"]
  node_u2_impl["U2Net architecture<br/>[u2net.py]"]
  node_bas_impl["BASNet architecture<br/>[basnet.py]"]
end

node_user(("User"))
node_image_files["Image files"]

node_user -->|"runs"| node_cli
node_user -->|"opens"| node_gui
node_gui -->|"displays"| node_web_ui
node_gui -->|"dispatches"| node_orchestrator
node_cli -->|"invokes"| node_orchestrator
node_image_files -->|"supplies input"| node_orchestrator
node_orchestrator -->|"saves results"| node_image_files
node_orchestrator -->|"selects model"| node_model_select
node_orchestrator -->|"selects method"| node_preprocess
node_orchestrator -->|"selects method"| node_postprocess
node_model_select -.->|"routes model"| node_u2_adapter
node_model_select -.->|"routes model"| node_bas_adapter
node_model_select -.->|"routes model"| node_tf_adapter
node_u2_adapter -->|"loads architecture"| node_u2_impl
node_bas_adapter -->|"loads architecture"| node_bas_impl
node_u2_adapter -->|"runs preprocessing"| node_preprocess
node_u2_adapter -->|"runs postprocessing"| node_postprocess
node_bas_adapter -->|"runs preprocessing"| node_preprocess
node_bas_adapter -->|"runs postprocessing"| node_postprocess
node_tf_adapter -->|"runs preprocessing"| node_preprocess
node_tf_adapter -->|"runs postprocessing"| node_postprocess
node_cli -->|"uses choices"| node_methods

click node_cli "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/main.py"
click node_gui "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/gui.py"
click node_web_ui "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/gui/index.html"
click node_orchestrator "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/main.py"
click node_preprocess "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/preprocessing.py"
click node_postprocess "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/postprocessing.py"
click node_model_select "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py"
click node_u2_adapter "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py"
click node_bas_adapter "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py"
click node_tf_adapter "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py"
click node_u2_impl "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/u2net.py"
click node_bas_impl "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/basnet.py"
click node_methods "https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/strings.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_cli,node_gui,node_web_ui,node_user toneBlue
class node_orchestrator,node_preprocess,node_postprocess,node_methods toneAmber
class node_model_select,node_u2_adapter,node_bas_adapter,node_tf_adapter toneMint
class node_u2_impl,node_bas_impl toneRose
class node_image_files toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/main.py): `main.py`
- [GUI](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/gui.py): `gui.py`
- [GUI page](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/gui/index.html): `gui/index.html`

### Image processing

- [Image workflow](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/main.py): `main.py`
- [Object preprocessing](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/preprocessing.py): `libs/preprocessing.py`
- [Boundary refinement](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/postprocessing.py): `libs/postprocessing.py`
- [Method names](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/strings.py): `libs/strings.py`

### Segmentation models

- [Model selection](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py): `libs/networks.py`
- [U2Net adapter](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py): `libs/networks.py`
- [BASNet adapter](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py): `libs/networks.py`
- [DeepLab adapter](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/networks.py): `libs/networks.py`

### Network implementations

- [U2Net architecture](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/u2net.py): `libs/u2net.py`
- [BASNet architecture](https://github.com/nandhakishorm/image-background-remove-tool/blob/master/libs/basnet.py): `libs/basnet.py`

### Other components

- **User**
- **Image files**

## Connections

- User → CLI: runs (evidence: `README.md`)
- User → GUI: opens (evidence: `README.md`)
- GUI → GUI page: displays (evidence: `gui.py`)
- GUI → Image workflow: dispatches (evidence: `gui.py`)
- CLI → Image workflow: invokes (evidence: `main.py`)
- Image files → Image workflow: supplies input (evidence: `main.py`)
- Image workflow → Image files: saves results (evidence: `main.py`)
- Image workflow → Model selection: selects model (evidence: `main.py`)
- Image workflow → Object preprocessing: selects method (evidence: `main.py`)
- Image workflow → Boundary refinement: selects method (evidence: `main.py`)
- Model selection → U2Net adapter: routes model (evidence: `libs/networks.py`)
- Model selection → BASNet adapter: routes model (evidence: `libs/networks.py`)
- Model selection → DeepLab adapter: routes model (evidence: `libs/networks.py`)
- U2Net adapter → U2Net architecture: loads architecture (evidence: `libs/networks.py`)
- BASNet adapter → BASNet architecture: loads architecture (evidence: `libs/networks.py`)
- U2Net adapter → Object preprocessing: runs preprocessing (evidence: `libs/networks.py`)
- U2Net adapter → Boundary refinement: runs postprocessing (evidence: `libs/networks.py`)
- BASNet adapter → Object preprocessing: runs preprocessing (evidence: `libs/networks.py`)
- BASNet adapter → Boundary refinement: runs postprocessing (evidence: `libs/networks.py`)
- DeepLab adapter → Object preprocessing: runs preprocessing (evidence: `libs/networks.py`)
- DeepLab adapter → Boundary refinement: runs postprocessing (evidence: `libs/networks.py`)
- CLI → Method names: uses choices (evidence: `main.py`)
