# fabianxox/sih26 architecture

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

- Interactive diagram: https://gitdiagram.com/fabianxox/sih26
- Repository: https://github.com/fabianxox/sih26

## Overview

This repository is an image-enhancement tool for producing e-commerce product images. The shown workflow starts at the app entry point, loads an image, removes its background, composites white, corrects lighting, crops around the product, formats a square output, and saves it. Separate capabilities include tiled ONNX upscaling and image-quality measurements. The quality modules and upscaler are not wired into the shown pipeline; the README is empty, so their integration and other unsampled behavior are not inferred.

Main entry points: [`image_enhancer/pipeline.py`](https://github.com/fabianxox/sih26/blob/main/image_enhancer/pipeline.py) (Image pipeline), [`image_enhancer/upscaler.py`](https://github.com/fabianxox/sih26/blob/main/image_enhancer/upscaler.py) (Tiled upscaler), [`image_enhancer/app.py`](https://github.com/fabianxox/sih26/blob/main/image_enhancer/app.py) (App entry), [`image_enhancer/segmentation/segment.py`](https://github.com/fabianxox/sih26/blob/main/image_enhancer/segmentation/segment.py) (Background removal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_app["App entry<br/>[app.py]"]
end

subgraph group_workflow["Product image workflow"]
  node_pipeline["Image pipeline<br/>[pipeline.py]"]
  node_segmentation["Background removal<br/>[segment.py]"]
  node_background["White compositing<br/>[background.py]"]
  node_lighting["Lighting correction<br/>[lighting.py]"]
  node_crop["Product cropping<br/>[crop.py]"]
  node_formatter["Output formatting<br/>[formatter.py]"]
end

subgraph group_quality["Quality analysis"]
  node_blur["Blur scoring<br/>[blur.py]"]
  node_brightness["Brightness scoring<br/>[brightness.py]"]
  node_resolution["Resolution checks<br/>[resolution.py]"]
end

subgraph group_upscale["AI upscaling"]
  node_upscaler["Tiled upscaler<br/>[upscaler.py]"]
  node_model["Upscaling model"]
end

node_user(("Image operator"))
node_rembg["rembg library"]
node_output["Enhanced image"]
node_onnx["ONNX Runtime"]

node_user -->|"starts"| node_app
node_app -->|"calls"| node_pipeline
node_pipeline -->|"segments"| node_segmentation
node_segmentation -->|"calls"| node_rembg
node_pipeline -->|"composites"| node_background
node_pipeline -->|"corrects lighting"| node_lighting
node_pipeline -->|"crops"| node_crop
node_pipeline -->|"formats"| node_formatter
node_pipeline -->|"saves"| node_output
node_upscaler -->|"runs inference"| node_onnx
node_upscaler -.->|"loads configured model"| node_model

click node_app "https://github.com/fabianxox/sih26/blob/main/image_enhancer/app.py"
click node_pipeline "https://github.com/fabianxox/sih26/blob/main/image_enhancer/pipeline.py"
click node_segmentation "https://github.com/fabianxox/sih26/blob/main/image_enhancer/segmentation/segment.py"
click node_background "https://github.com/fabianxox/sih26/blob/main/image_enhancer/enhancement/background.py"
click node_lighting "https://github.com/fabianxox/sih26/blob/main/image_enhancer/enhancement/lighting.py"
click node_crop "https://github.com/fabianxox/sih26/blob/main/image_enhancer/enhancement/crop.py"
click node_formatter "https://github.com/fabianxox/sih26/blob/main/image_enhancer/output/formatter.py"
click node_blur "https://github.com/fabianxox/sih26/blob/main/image_enhancer/quality/blur.py"
click node_brightness "https://github.com/fabianxox/sih26/blob/main/image_enhancer/quality/brightness.py"
click node_resolution "https://github.com/fabianxox/sih26/blob/main/image_enhancer/quality/resolution.py"
click node_upscaler "https://github.com/fabianxox/sih26/blob/main/image_enhancer/upscaler.py"
click node_model "https://github.com/fabianxox/sih26/blob/main/image_enhancer/models/RealESRGAN_x4plus.onnx"

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_app toneBlue
class node_pipeline,node_segmentation,node_background,node_lighting,node_crop,node_formatter toneAmber
class node_blur,node_brightness,node_resolution toneMint
class node_upscaler,node_model toneRose
class node_user,node_rembg,node_output,node_onnx toneIndigo
```

## Components

### Application entry

- [App entry](https://github.com/fabianxox/sih26/blob/main/image_enhancer/app.py): `image_enhancer/app.py`

### Product image workflow

- [Image pipeline](https://github.com/fabianxox/sih26/blob/main/image_enhancer/pipeline.py): `image_enhancer/pipeline.py`
- [Background removal](https://github.com/fabianxox/sih26/blob/main/image_enhancer/segmentation/segment.py): `image_enhancer/segmentation/segment.py`
- [White compositing](https://github.com/fabianxox/sih26/blob/main/image_enhancer/enhancement/background.py): `image_enhancer/enhancement/background.py`
- [Lighting correction](https://github.com/fabianxox/sih26/blob/main/image_enhancer/enhancement/lighting.py): `image_enhancer/enhancement/lighting.py`
- [Product cropping](https://github.com/fabianxox/sih26/blob/main/image_enhancer/enhancement/crop.py): `image_enhancer/enhancement/crop.py`
- [Output formatting](https://github.com/fabianxox/sih26/blob/main/image_enhancer/output/formatter.py): `image_enhancer/output/formatter.py`

### Quality analysis

- [Blur scoring](https://github.com/fabianxox/sih26/blob/main/image_enhancer/quality/blur.py): `image_enhancer/quality/blur.py`
- [Brightness scoring](https://github.com/fabianxox/sih26/blob/main/image_enhancer/quality/brightness.py): `image_enhancer/quality/brightness.py`
- [Resolution checks](https://github.com/fabianxox/sih26/blob/main/image_enhancer/quality/resolution.py): `image_enhancer/quality/resolution.py`

### AI upscaling

- [Tiled upscaler](https://github.com/fabianxox/sih26/blob/main/image_enhancer/upscaler.py): `image_enhancer/upscaler.py`
- [Upscaling model](https://github.com/fabianxox/sih26/blob/main/image_enhancer/models/RealESRGAN_x4plus.onnx): `image_enhancer/models/RealESRGAN_x4plus.onnx`

### Other components

- **Image operator**
- **rembg library**
- **Enhanced image**
- **ONNX Runtime**

## Connections

- Image operator → App entry: starts
- App entry → Image pipeline: calls (evidence: `image_enhancer/app.py`)
- Image pipeline → Background removal: segments (evidence: `image_enhancer/pipeline.py`)
- Background removal → rembg library: calls (evidence: `image_enhancer/segmentation/segment.py`)
- Image pipeline → White compositing: composites (evidence: `image_enhancer/pipeline.py`)
- Image pipeline → Lighting correction: corrects lighting (evidence: `image_enhancer/pipeline.py`)
- Image pipeline → Product cropping: crops (evidence: `image_enhancer/pipeline.py`)
- Image pipeline → Output formatting: formats (evidence: `image_enhancer/pipeline.py`)
- Image pipeline → Enhanced image: saves (evidence: `image_enhancer/pipeline.py`)
- Tiled upscaler → ONNX Runtime: runs inference (evidence: `image_enhancer/upscaler.py`)
- Tiled upscaler → Upscaling model: loads configured model
