# veraposeidon/labelme2datasets architecture

> Architecture diagram of the GitHub repository veraposeidon/labelme2datasets, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/veraposeidon/labelme2datasets
- Repository: https://github.com/veraposeidon/labelme2datasets

## Overview

##### Main Components
- Input Data: Represent the “data” directory where users place LabelMe JSON files, the label_names.txt for class names, and optionally the label_dict.txt for label conversions.
- Conversion Modules:
- labelme_json2dataset: Converts a single JSON file into a dataset output.
- labelme_bbox_json2voc: Processes a folder of JSON files into a VOC-formatted dataset. It further considers optional label conversion using label_dict.
- split_voc_datasets: Splits the generated VOC dataset into training and testing sets.
- voc2coco: Converts a VOC dataset into a COCO-formatted dataset.

##### Relationships and Interactions
- How input data (LabelMe JSONs and label text files) feed into the conversion modules.
- If applicable, show optional flows – for instance, if a label conversion file is provided (label_dict.txt), then it affects the output in the VOC conversion script.
- Cascading flow: conversion from raw JSON to VOC format, optional splitting of the VOC dataset into train/test sets, and subsequent conversion from VOC to COCO format.

##### Architectural Patterns or Design Principles
- A modular design where each script is responsible for a well-defined task.
- That the design is organized in a “data pipeline” fashion, where the output of one script can serve as the input to another.
- Separation of concerns – file processing and data conversion are isolated within separate Python modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Data Input"
        ID["Input Data (LabelMe JSONs, label_names.txt, label_dict.txt)"]:::input
    end

    subgraph "Conversion Modules"
        L1["labelme_json2dataset (Single JSON conversion)"]:::process
        L2["labelme_bbox_json2voc (Folder JSON → VOC conversion)"]:::process
        L3["split_voc_datasets (VOC dataset splitting)"]:::process
        L4["voc2coco (VOC to COCO conversion)"]:::process
    end

    subgraph "Output"
        Out["Output Directories (test_single_output, test_voc_output, test_coco_output)"]:::output
    end

    subgraph "CI"
        CI["GitHub Actions"]:::ci
    end

    %% Data flow arrows
    ID -->|"JSON_file"| L1
    L1 -->|"Single_Output"| Out

    ID -->|"JSON_folder"| L2
    ID -->|"label_mapping"| L2
    L2 -->|"VOC_dataset"| L3
    L3 -->|"TrainTest_Split"| L4
    L4 -->|"COCO_dataset"| Out

    %% CI integration arrows
    CI -->|"runs_tests"| L1
    CI -->|"runs_tests"| L2
    CI -->|"runs_tests"| L3
    CI -->|"runs_tests"| L4

    %% Click Events
    click ID "https://github.com/veraposeidon/labelme2datasets/tree/main/data/"
    click L1 "https://github.com/veraposeidon/labelme2datasets/blob/main/labelme2datasets/labelme_json2dataset.py"
    click L2 "https://github.com/veraposeidon/labelme2datasets/blob/main/labelme2datasets/labelme_bbox_json2voc.py"
    click L3 "https://github.com/veraposeidon/labelme2datasets/blob/main/labelme2datasets/split_voc_datasets.py"
    click L4 "https://github.com/veraposeidon/labelme2datasets/blob/main/labelme2datasets/voc2coco.py"
    click Out "https://github.com/veraposeidon/labelme2datasets/tree/main/output/"
    click CI "https://github.com/veraposeidon/labelme2datasets/tree/main/.github/workflows/"

    %% Styles
    classDef input fill:#FFF2CC,stroke:#D6B656,stroke-width:2px;
    classDef process fill:#D5E8D4,stroke:#82B366,stroke-width:2px;
    classDef output fill:#DAE8FC,stroke:#6C8EBF,stroke-width:2px;
    classDef ci fill:#F8CECC,stroke:#B85450,stroke-width:2px,stroke-dasharray: 5, 5;
```
