# pengyu-gis/zs-treeseg architecture

> Architecture diagram of the GitHub repository pengyu-gis/zs-treeseg, 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/pengyu-gis/zs-treeseg
- Repository: https://github.com/pengyu-gis/zs-treeseg

## Overview

FG-TreeSeg is a README-contained, training-free pipeline for zero-shot tree-crown instance segmentation. The demo loads a sample image, obtains a SegFormer canopy mask, uses that mask to constrain Cellpose-SAM flow-based instance separation, and visualizes the results. The README documents the runtime relationships; no separate implementation files are present in the tree.

Main entry points: [`README.md`](https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md) (Demo runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_demo["Demo workflow"]
  node_demo_runner["Demo runner<br/>[README.md]"]
  node_sample_data[("Sample dataset")]
  node_visualization["Result visualization<br/>[README.md]"]
end

subgraph group_semantic["Semantic suppression"]
  node_semantic_mask["Canopy mask<br/>[README.md]"]
  node_segformer_processor["SegFormer processor"]
  node_segformer_model["SegFormer model"]
end

subgraph group_instances["Instance separation"]
  node_image_prep["Mask and smooth<br/>[README.md]"]
  node_cellpose["Cellpose-SAM"]
  node_instance_mask["Instance mask<br/>[README.md]"]
end

node_user(("User"))

node_user -->|"runs demo"| node_demo_runner
node_demo_runner -->|"loads sample"| node_sample_data
node_demo_runner -->|"requests mask"| node_semantic_mask
node_semantic_mask -->|"prepares input"| node_segformer_processor
node_semantic_mask -->|"infers classes"| node_segformer_model
node_demo_runner -->|"runs segmentation"| node_image_prep
node_image_prep -->|"evaluates flows"| node_cellpose
node_image_prep -->|"applies constraint"| node_semantic_mask
node_image_prep -->|"masks instances"| node_instance_mask
node_demo_runner -->|"displays outputs"| node_visualization
node_semantic_mask -->|"supplies mask"| node_visualization
node_cellpose -->|"supplies flows"| node_visualization
node_instance_mask -->|"supplies instances"| node_visualization

click node_demo_runner "https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md"
click node_semantic_mask "https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md"
click node_image_prep "https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md"
click node_instance_mask "https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md"
click node_visualization "https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md"

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_demo_runner,node_sample_data,node_visualization,node_user toneBlue
class node_semantic_mask,node_segformer_processor,node_segformer_model toneAmber
class node_image_prep,node_cellpose,node_instance_mask toneMint
```

## Components

### Demo workflow

- [Demo runner](https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md): `README.md`
- **Sample dataset**
- [Result visualization](https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md): `README.md`

### Semantic suppression

- [Canopy mask](https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md): `README.md`
- **SegFormer processor**
- **SegFormer model**

### Instance separation

- [Mask and smooth](https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md): `README.md`
- **Cellpose-SAM**
- [Instance mask](https://github.com/pengyu-gis/zs-treeseg/blob/main/README.md): `README.md`

### Other components

- **User**

## Connections

- User → Demo runner: runs demo (evidence: `README.md`)
- Demo runner → Sample dataset: loads sample (evidence: `README.md`)
- Demo runner → Canopy mask: requests mask (evidence: `README.md`)
- Canopy mask → SegFormer processor: prepares input (evidence: `README.md`)
- Canopy mask → SegFormer model: infers classes (evidence: `README.md`)
- Demo runner → Mask and smooth: runs segmentation (evidence: `README.md`)
- Mask and smooth → Cellpose-SAM: evaluates flows (evidence: `README.md`)
- Mask and smooth → Canopy mask: applies constraint (evidence: `README.md`)
- Mask and smooth → Instance mask: masks instances (evidence: `README.md`)
- Demo runner → Result visualization: displays outputs (evidence: `README.md`)
- Canopy mask → Result visualization: supplies mask (evidence: `README.md`)
- Cellpose-SAM → Result visualization: supplies flows (evidence: `README.md`)
- Instance mask → Result visualization: supplies instances (evidence: `README.md`)
