# shyamanth-2005/label-studio-setup architecture

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

- Interactive diagram: https://gitdiagram.com/shyamanth-2005/label-studio-setup
- Repository: https://github.com/shyamanth-2005/label-studio-setup

## Overview

This repository provides two YOLOv8 backends for Label Studio: object detection returns bounding-box annotations, while segmentation returns polygon annotations. In each variant, Label Studio sends setup or prediction requests to a FastAPI service; the service delegates model lifecycle and prediction requests to Label Studio’s ML manager, and the model class loads its configured weights, resolves task images, runs inference, and formats annotations. The README documents both modes and the health endpoint. Relationships shown are supported by the README or sampled source; external library internals are not shown.

Main entry points: [`app.py`](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py) (Detection Model), [`app_seg.py`](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py) (Segmentation Model), [`config.py`](https://github.com/shyamanth-2005/label-studio-setup/blob/main/config.py) (Model Paths)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_service["Backend Service"]
  node_detection_api["Detection API<br/>[app.py]"]
  node_detection_manager["Detection ML Manager<br/>[app.py]"]
  node_detection_setup["Detection Setup<br/>[app.py]"]
  node_detection_predict_route["Detection Predict Route<br/>[app.py]"]
  node_health["Health Check<br/>[app.py]"]
  node_segmentation_api["Segmentation API<br/>[app_seg.py]"]
  node_segmentation_manager["Segmentation ML Manager<br/>[app_seg.py]"]
  node_segmentation_setup["Segmentation Setup<br/>[app_seg.py]"]
  node_segmentation_predict_route["Segmentation Predict Route<br/>[app_seg.py]"]
end

subgraph group_detection["Detection Backend"]
  node_detection_model["Detection Model<br/>[app.py]"]
  node_detection_config["Model Paths<br/>[config.py]"]
  node_detection_inference["Box Inference<br/>[app.py]"]
end

subgraph group_segmentation["Segmentation Backend"]
  node_segmentation_model["Segmentation Model<br/>[app_seg.py]"]
  node_segmentation_config["Model Paths<br/>[config.py]"]
  node_polygon_inference["Polygon Inference<br/>[app_seg.py]"]
end

node_label_studio(("Label Studio"))
node_yolo["YOLOv8"]
node_image_resolver["Image Path Resolver"]
node_ml_framework["Label Studio ML Framework"]

node_label_studio -->|"sends requests"| node_detection_api
node_label_studio -->|"sends requests"| node_segmentation_api
node_detection_api -->|"initializes"| node_detection_manager
node_detection_manager -->|"registers"| node_detection_model
node_detection_predict_route -->|"requests predictions"| node_detection_manager
node_detection_setup -->|"fetches model"| node_detection_manager
node_detection_api -->|"serves health"| node_health
node_detection_model -->|"reads weights"| node_detection_config
node_detection_model -->|"loads model"| node_yolo
node_detection_model -->|"resolves image"| node_image_resolver
node_detection_model -->|"formats boxes"| node_detection_inference
node_detection_inference -->|"runs prediction"| node_yolo
node_segmentation_api -->|"initializes"| node_segmentation_manager
node_segmentation_manager -->|"registers"| node_segmentation_model
node_segmentation_predict_route -->|"requests predictions"| node_segmentation_manager
node_segmentation_setup -->|"fetches model"| node_segmentation_manager
node_segmentation_api -->|"serves health"| node_health
node_segmentation_model -->|"reads weights"| node_segmentation_config
node_segmentation_model -->|"loads model"| node_yolo
node_segmentation_model -->|"resolves image"| node_image_resolver
node_segmentation_model -->|"formats polygons"| node_polygon_inference
node_polygon_inference -->|"runs prediction"| node_yolo
node_detection_manager -->|"uses framework"| node_ml_framework
node_segmentation_manager -->|"uses framework"| node_ml_framework

click node_detection_api "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py"
click node_detection_manager "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py"
click node_detection_setup "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py"
click node_detection_predict_route "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py"
click node_health "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py"
click node_detection_model "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py"
click node_detection_config "https://github.com/shyamanth-2005/label-studio-setup/blob/main/config.py"
click node_detection_inference "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py"
click node_segmentation_api "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py"
click node_segmentation_manager "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py"
click node_segmentation_setup "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py"
click node_segmentation_predict_route "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py"
click node_segmentation_model "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py"
click node_segmentation_config "https://github.com/shyamanth-2005/label-studio-setup/blob/main/config.py"
click node_polygon_inference "https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.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_detection_api,node_detection_manager,node_detection_setup,node_detection_predict_route,node_health,node_segmentation_api,node_segmentation_manager,node_segmentation_setup,node_segmentation_predict_route toneBlue
class node_detection_model,node_detection_config,node_detection_inference toneAmber
class node_segmentation_model,node_segmentation_config,node_polygon_inference toneMint
class node_label_studio,node_yolo,node_image_resolver,node_ml_framework toneIndigo
```

## Components

### Backend Service

- [Detection API](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py): `app.py`
- [Detection ML Manager](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py): `app.py`
- [Detection Setup](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py): `app.py`
- [Detection Predict Route](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py): `app.py`
- [Health Check](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py): `app.py`
- [Segmentation API](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py): `app_seg.py`
- [Segmentation ML Manager](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py): `app_seg.py`
- [Segmentation Setup](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py): `app_seg.py`
- [Segmentation Predict Route](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py): `app_seg.py`

### Detection Backend

- [Detection Model](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py): `app.py`
- [Model Paths](https://github.com/shyamanth-2005/label-studio-setup/blob/main/config.py): `config.py`
- [Box Inference](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app.py): `app.py`

### Segmentation Backend

- [Segmentation Model](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py): `app_seg.py`
- [Model Paths](https://github.com/shyamanth-2005/label-studio-setup/blob/main/config.py): `config.py`
- [Polygon Inference](https://github.com/shyamanth-2005/label-studio-setup/blob/main/app_seg.py): `app_seg.py`

### Other components

- **Label Studio**
- **YOLOv8**
- **Image Path Resolver**
- **Label Studio ML Framework**

## Connections

- Label Studio → Detection API: sends requests (evidence: `README.md`)
- Label Studio → Segmentation API: sends requests (evidence: `README.md`)
- Detection API → Detection ML Manager: initializes (evidence: `app.py`)
- Detection ML Manager → Detection Model: registers (evidence: `app.py`)
- Detection Predict Route → Detection ML Manager: requests predictions (evidence: `app.py`)
- Detection Setup → Detection ML Manager: fetches model (evidence: `app.py`)
- Detection API → Health Check: serves health (evidence: `app.py`)
- Detection Model → Model Paths: reads weights (evidence: `app.py`)
- Detection Model → YOLOv8: loads model (evidence: `app.py`)
- Detection Model → Image Path Resolver: resolves image (evidence: `app.py`)
- Detection Model → Box Inference: formats boxes (evidence: `app.py`)
- Box Inference → YOLOv8: runs prediction (evidence: `app.py`)
- Segmentation API → Segmentation ML Manager: initializes (evidence: `app_seg.py`)
- Segmentation ML Manager → Segmentation Model: registers (evidence: `app_seg.py`)
- Segmentation Predict Route → Segmentation ML Manager: requests predictions (evidence: `app_seg.py`)
- Segmentation Setup → Segmentation ML Manager: fetches model (evidence: `app_seg.py`)
- Segmentation API → Health Check: serves health (evidence: `app_seg.py`)
- Segmentation Model → Model Paths: reads weights (evidence: `app_seg.py`)
- Segmentation Model → YOLOv8: loads model (evidence: `app_seg.py`)
- Segmentation Model → Image Path Resolver: resolves image (evidence: `app_seg.py`)
- Segmentation Model → Polygon Inference: formats polygons (evidence: `app_seg.py`)
- Polygon Inference → YOLOv8: runs prediction (evidence: `app_seg.py`)
- Detection ML Manager → Label Studio ML Framework: uses framework (evidence: `app.py`)
- Segmentation ML Manager → Label Studio ML Framework: uses framework (evidence: `app_seg.py`)
