How gaia-dental-studio/dental_smile_design works
The Dental Smile Design project is a specialized computer vision application that implements a multi-stage pipeline for tooth alignment in facial photographs. Its purpose is to process an input facial image, detect and segment facial features (like the face, mouth, and teeth), and then perform a transformation (or “alignment”) based on 3D structure guidance. The project is structured in clearly delineated stages that mirror the various steps in the processing pipeline.
Main Components
• Input Module: Represented by the Data directory which contains input images (e.g., facial photographs).
• Processing Pipeline (Backend Core):
• Stage1 – Preprocessing and Feature Detection:
• DetectFace: Identifies facial landmarks using provided models (e.g., the 68-face landmark predictor).
• DetectMouth: Identifies and processes the mouth region.
• Tooth Segmentation Modules: SegmentTeeth and SegmentToothContour to extract and refine tooth contours.
• Stage2 – First Generation/Transformation:
• Contains Generator.py and Network.py that likely perform an initial transformation (using configurations provided in the config subdirectory and pretrained weights from ckpt).
• Stage3 – Refinement/Final Output Generation:
• Output Module: The Output directory stores the resulting aligned images and intermediate processing outputs.
• Model Restoration and Auxiliary Code:
• The Restore folder that may include code for recovering or reinitializing models.
• Helper files such as helper.py, settings.py, and configuration files such as Code/Config.yaml and those under Code/config.
• External Interfaces:
• API Interface: Provided by api.py (a Flask-based API) and app.py (Streamlit-based UI) to allow users to interact with the model through web interfaces.
• Main Execution scripts such as main.py and main_ForFolder.py, which serve as entry points for running the complete pipeline.
Relationships and Data Flow
• Input images (from Data) are fed into the main program (main.py) or the user interface (Streamlit or Flask API).
• The image then flows into Stage1 where feature detection (face, mouth, boundaries) is executed.
• The pre-processed data then moves through Stage2 and subsequently Stage3. Each stage refines the prediction:
• Stage2 processes initial contour to contour or mask-to-mask conversions.
• Stage3 further refines the results from Stage2, applying additional configuration options (e.g., different rendering styles, applying Fourier descriptors).
• The final processed images are saved into the Output directory (organized into prediction and processing subdirectories).
Architectural Patterns and Technologies
• Modular design, with each stage (detection, generation, refinement) handled in separate directories and scripts.
• Clearly defined checkpoints (ckpt files) for deep learning models across stages, emphasizing a dependency on pretrained weights and configuration-driven behavior.
• Use of multiple interfaces (command-line via main.py, Flask API via api.py, and Streamlit interface via app.py) demonstrating a layered architecture using backend processing with different presentation/UI layers.
Specific Elements to Be Included
• Clear, descriptive labels for each major component (e.g., “Data Input”, “Stage1: Feature Detection”, “Stage2: Initial Generation”, “Stage3: Refinement”, “API/Streamlit Interfaces”).
• Annotations or notes indicating where model checkpoints and configuration files are used.