# yeonsumia/palmistry architecture

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

- Interactive diagram: https://gitdiagram.com/yeonsumia/palmistry
- Repository: https://github.com/yeonsumia/palmistry

## Overview

##### Project type and purpose
- This is a single-machine, Python-based image-processing pipeline for view-invariant palm line analysis. It takes HEIC/JPG palm images, rectifies them to a standard pose, detects principal lines via a deep model, classifies those lines, and measures their lengths.

##### File structure
- Top-level modules:
- code/: main pipeline code and driver script (read_palm.py)
- warp/: traditional and v2 warping implementations
- classification/: line grouping & classification utilities
- detect/: experimental notebooks and saved model checkpoints
- Key scripts in code/:
- rectification.py – uses MediaPipe to extract landmarks
- warping*.py – uses those landmarks to warp the image
- detection.py & model.py – loads a PyTorch model to detect lines
- classification.py & lineseg.py – skeletonizes and groups pixels, then K-means to label line segments
- measurement.py – calculates length per line using thresholds and landmarks
- tools.py – shared helpers (I/O, visualization)

##### README for additional insights
- Four clear pipeline steps: warping, detection, classification, measurement
- External libs: MediaPipe, PyTorch/torchvision, scikit-image, OpenCV, pillow-heif
- Entry point: code/read_palm.py, which orchestrates the steps

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Orchestration
    ORC["Orchestrator\nread_palm.py"]:::pythonModule
    click ORC "https://github.com/yeonsumia/palmistry/blob/main/code/read_palm.py"

    %% Pipeline Steps
    IM["Input Module\n(code/input/)"]:::pythonModule
    click IM "https://github.com/yeonsumia/palmistry/tree/main/code/input/"

    RC["Rectification Module\nrectification.py"]:::pythonModule
    click RC "https://github.com/yeonsumia/palmistry/blob/main/code/rectification.py"

    WM1["Warping Module\ntraditional"]:::pythonModule
    click WM1 "https://github.com/yeonsumia/palmistry/blob/main/warp/warping_traditional.py"
    WM2["Warping Module\nv2"]:::pythonModule
    click WM2 "https://github.com/yeonsumia/palmistry/blob/main/warp/warping_v2.py"

    DM["Line Detection Module\ndetection.py"]:::pythonModule
    click DM "https://github.com/yeonsumia/palmistry/blob/main/code/detection.py"
    MD["Model Definition\nmodel.py"]:::pythonModule
    click MD "https://github.com/yeonsumia/palmistry/blob/main/code/model.py"

    CP["Checkpoints & Sandbox"]:::model
    click CP "https://github.com/yeonsumia/palmistry/tree/main/detect/checkpoints/"
    NB["Detector Notebook"]:::notebook
    click NB "https://github.com/yeonsumia/palmistry/blob/main/detect/palmistry_detector.ipynb"

    SC["Segmentation & Classification\nclassification.py"]:::pythonModule
    click SC "https://github.com/yeonsumia/palmistry/blob/main/code/classification.py"
    LS["Line Segmentation Utils\nlineseg.py"]:::pythonModule
    click LS "https://github.com/yeonsumia/palmistry/blob/main/classification/lineseg.py"
    LC["Line Classification Utils\nline_classifier.py"]:::pythonModule
    click LC "https://github.com/yeonsumia/palmistry/blob/main/classification/line_classifier.py"

    MM["Measurement Module\nmeasurement.py"]:::pythonModule
    click MM "https://github.com/yeonsumia/palmistry/blob/main/code/measurement.py"

    OM["Output Module\n(detect/outputs/)"]:::storage
    click OM "https://github.com/yeonsumia/palmistry/tree/main/detect/outputs/"

    RD["Results Directories\nresults/, results2/"]:::storage
    click RD "https://github.com/yeonsumia/palmistry/tree/main/results/"

    REQ["Requirements\nrequirements.txt"]:::storage
    click REQ "https://github.com/yeonsumia/palmistry/blob/main/code/requirements.txt"

    %% External Libraries
    MP[(MediaPipe)]:::extLib
    OC[(OpenCV & pillow-heif)]:::extLib
    PT[(PyTorch/torchvision)]:::extLib
    SI[(scikit-image)]:::extLib
    SK[(scikit-learn)]:::extLib

    %% Pipeline Flow
    IM -->|"raw image"| RC
    RC -->|"landmarks"| WM1
    RC -->|"landmarks"| WM2
    WM1 -->|"warped image"| DM
    WM1 -->|"warped image"| SC
    WM2 -->|"warped image"| DM
    WM2 -->|"warped image"| SC
    DM -->|"line mask"| SC
    SC -->|"segment labels"| MM
    MM -->|"measurements"| OM
    OM --> RD

    %% Orchestration Calls
    ORC -.-> IM
    ORC -.-> RC
    ORC -.-> WM1
    ORC -.-> WM2
    ORC -.-> DM
    ORC -.-> SC
    ORC -.-> MM
    ORC -.-> OM

    %% Module Dependencies on External Libraries
    RC --> MP
    RC --> OC
    WM1 --> OC
    WM2 --> OC
    DM --> PT
    MD --> PT
    SC --> SI
    SC --> SK
    MM --> OC

    %% Checkpoints Relation
    DM --> CP
    DM --> NB

    %% Legend
    subgraph Legend
        direction TB
        P["Python Module"]:::pythonModule
        E["External Library"]:::extLib
        M["Model Artifact"]:::model
        N["Notebook"]:::notebook
        S["Storage"]:::storage
    end

    classDef pythonModule fill:#ADD8E6,stroke:#000,color:#000
    classDef extLib fill:#90EE90,stroke:#000,color:#000
    classDef model fill:#FFD700,stroke:#000,color:#000
    classDef notebook fill:#D3D3D3,stroke:#000,color:#000
    classDef storage fill:#FFB6C1,stroke:#000,color:#000
```
