# nomadthegrey/image-to-model architecture

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

- Interactive diagram: https://gitdiagram.com/nomadthegrey/image-to-model
- Repository: https://github.com/nomadthegrey/image-to-model

## Overview

This is a local Gradio image-to-3D converter. The main workflow accepts an image and generation settings, routes the request through a configurable engine, optionally removes the background, runs TripoSR inference, extracts a mesh, and exports downloadable models that can be revisited through history. The model internals include image/triplane tokenization, transformer layers, and rendering utilities. README documents additional UI and export capabilities; sampled excerpts do not expose every implementation call, so uncertain internal links are omitted or marked dashed.

Main entry points: [`tsr/system.py`](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/system.py) (TripoSR system), [`engines/local_triposr.py`](https://github.com/nomadthegrey/image-to-model/blob/main/engines/local_triposr.py) (Local engine), [`app.py`](https://github.com/nomadthegrey/image-to-model/blob/main/app.py) (Gradio UI), [`engines/__init__.py`](https://github.com/nomadthegrey/image-to-model/blob/main/engines/__init__.py) (Engine dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_webui["Gradio UI<br/>[app.py]"]
  node_history["Model history<br/>[app.py]"]
end

subgraph group_engine["Engine routing"]
  node_settings["App settings<br/>[config.py]"]
  node_dispatch["Engine dispatcher<br/>[__init__.py]"]
end

subgraph group_generation["Local generation"]
  node_local["Local engine<br/>[local_triposr.py]"]
  node_cloud["Cloud stub<br/>[cloud_api.py]"]
  node_background["Background removal<br/>[local_triposr.py]"]
  node_model_load["Model loading<br/>[local_triposr.py]"]
end

subgraph group_model["TripoSR model"]
  node_inference["TripoSR system<br/>[system.py]"]
  node_image_tokens["Image tokenizer<br/>[image.py]"]
  node_triplane_tokens["Triplane tokenizer<br/>[triplane.py]"]
  node_transformer_1d["1D transformer<br/>[transformer_1d.py]"]
  node_transformer_block["Transformer block"]
  node_attention["Attention<br/>[attention.py]"]
  node_network["Network utilities<br/>[network_utils.py]"]
  node_renderer["NeRF renderer<br/>[nerf_renderer.py]"]
  node_isosurface["Mesh extraction<br/>[isosurface.py]"]
  node_texture["Texture baking<br/>[bake_texture.py]"]
  node_utilities["Model utilities<br/>[utils.py]"]
end

node_person(("User"))
node_huggingface["Hugging Face"]

node_person -->|"uploads image"| node_webui
node_webui -->|"requests generation"| node_dispatch
node_settings -->|"selects engine"| node_dispatch
node_dispatch -->|"routes to"| node_local
node_dispatch -->|"routes to"| node_cloud
node_local -->|"isolates subject"| node_background
node_local -->|"loads model"| node_model_load
node_model_load -->|"downloads weights"| node_huggingface
node_local -->|"runs inference"| node_inference
node_inference -.->|"tokenizes image"| node_image_tokens
node_inference -.->|"creates tokens"| node_triplane_tokens
node_inference -.->|"predicts features"| node_transformer_1d
node_transformer_1d -->|"uses blocks"| node_transformer_block
node_transformer_block -->|"applies attention"| node_attention
node_inference -.->|"queries triplanes"| node_renderer
node_inference -->|"extracts surface"| node_isosurface
node_local -.->|"bakes texture"| node_texture
node_local -->|"exports models"| node_history
node_history -->|"reloads models"| node_webui
node_webui -->|"previews and downloads"| node_person
node_inference -.->|"uses utilities"| node_network
node_renderer -->|"uses helpers"| node_utilities

click node_webui "https://github.com/nomadthegrey/image-to-model/blob/main/app.py"
click node_history "https://github.com/nomadthegrey/image-to-model/blob/main/app.py"
click node_settings "https://github.com/nomadthegrey/image-to-model/blob/main/config.py"
click node_dispatch "https://github.com/nomadthegrey/image-to-model/blob/main/engines/__init__.py"
click node_local "https://github.com/nomadthegrey/image-to-model/blob/main/engines/local_triposr.py"
click node_cloud "https://github.com/nomadthegrey/image-to-model/blob/main/engines/cloud_api.py"
click node_background "https://github.com/nomadthegrey/image-to-model/blob/main/engines/local_triposr.py"
click node_model_load "https://github.com/nomadthegrey/image-to-model/blob/main/engines/local_triposr.py"
click node_inference "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/system.py"
click node_image_tokens "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/tokenizers/image.py"
click node_triplane_tokens "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/tokenizers/triplane.py"
click node_transformer_1d "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/transformer/transformer_1d.py"
click node_transformer_block "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/transformer/basic_transformer_block.py"
click node_attention "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/transformer/attention.py"
click node_network "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/network_utils.py"
click node_renderer "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/nerf_renderer.py"
click node_isosurface "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/isosurface.py"
click node_texture "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/bake_texture.py"
click node_utilities "https://github.com/nomadthegrey/image-to-model/blob/main/tsr/utils.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_webui,node_history,node_person toneBlue
class node_settings,node_dispatch toneAmber
class node_local,node_cloud,node_background,node_model_load toneMint
class node_inference,node_image_tokens,node_triplane_tokens,node_transformer_1d,node_transformer_block,node_attention,node_network,node_renderer,node_isosurface,node_texture,node_utilities toneRose
class node_huggingface toneIndigo
```

## Components

### Web interface

- [Gradio UI](https://github.com/nomadthegrey/image-to-model/blob/main/app.py): `app.py`
- [Model history](https://github.com/nomadthegrey/image-to-model/blob/main/app.py): `app.py`

### Engine routing

- [App settings](https://github.com/nomadthegrey/image-to-model/blob/main/config.py): `config.py`
- [Engine dispatcher](https://github.com/nomadthegrey/image-to-model/blob/main/engines/__init__.py): `engines/__init__.py`

### Local generation

- [Local engine](https://github.com/nomadthegrey/image-to-model/blob/main/engines/local_triposr.py): `engines/local_triposr.py`
- [Cloud stub](https://github.com/nomadthegrey/image-to-model/blob/main/engines/cloud_api.py): `engines/cloud_api.py`
- [Background removal](https://github.com/nomadthegrey/image-to-model/blob/main/engines/local_triposr.py): `engines/local_triposr.py`
- [Model loading](https://github.com/nomadthegrey/image-to-model/blob/main/engines/local_triposr.py): `engines/local_triposr.py`

### TripoSR model

- [TripoSR system](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/system.py): `tsr/system.py`
- [Image tokenizer](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/tokenizers/image.py): `tsr/models/tokenizers/image.py`
- [Triplane tokenizer](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/tokenizers/triplane.py): `tsr/models/tokenizers/triplane.py`
- [1D transformer](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/transformer/transformer_1d.py): `tsr/models/transformer/transformer_1d.py`
- [Transformer block](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/transformer/basic_transformer_block.py): `tsr/models/transformer/basic_transformer_block.py`
- [Attention](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/transformer/attention.py): `tsr/models/transformer/attention.py`
- [Network utilities](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/network_utils.py): `tsr/models/network_utils.py`
- [NeRF renderer](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/nerf_renderer.py): `tsr/models/nerf_renderer.py`
- [Mesh extraction](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/models/isosurface.py): `tsr/models/isosurface.py`
- [Texture baking](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/bake_texture.py): `tsr/bake_texture.py`
- [Model utilities](https://github.com/nomadthegrey/image-to-model/blob/main/tsr/utils.py): `tsr/utils.py`

### Other components

- **User**
- **Hugging Face**

## Connections

- User → Gradio UI: uploads image (evidence: `README.md`)
- Gradio UI → Engine dispatcher: requests generation (evidence: `README.md`)
- App settings → Engine dispatcher: selects engine (evidence: `engines/__init__.py`)
- Engine dispatcher → Local engine: routes to (evidence: `engines/__init__.py`)
- Engine dispatcher → Cloud stub: routes to (evidence: `engines/__init__.py`)
- Local engine → Background removal: isolates subject (evidence: `README.md`)
- Local engine → Model loading: loads model (evidence: `engines/local_triposr.py`)
- Model loading → Hugging Face: downloads weights (evidence: `engines/local_triposr.py`)
- Local engine → TripoSR system: runs inference (evidence: `engines/local_triposr.py`)
- TripoSR system → Image tokenizer: tokenizes image
- TripoSR system → Triplane tokenizer: creates tokens
- TripoSR system → 1D transformer: predicts features
- 1D transformer → Transformer block: uses blocks (evidence: `tsr/models/transformer/transformer_1d.py`)
- Transformer block → Attention: applies attention (evidence: `tsr/models/transformer/basic_transformer_block.py`)
- TripoSR system → NeRF renderer: queries triplanes
- TripoSR system → Mesh extraction: extracts surface (evidence: `tsr/system.py`)
- Local engine → Texture baking: bakes texture
- Local engine → Model history: exports models (evidence: `README.md`)
- Model history → Gradio UI: reloads models (evidence: `app.py`)
- Gradio UI → User: previews and downloads (evidence: `README.md`)
- TripoSR system → Network utilities: uses utilities
- NeRF renderer → Model utilities: uses helpers (evidence: `tsr/models/nerf_renderer.py`)
