How tapaskumardutta1/sketchfusion works
Project Type and Purpose
• SketchFusion is a computer vision research project that fuses foundation models – specifically, the semantic strength of CLIP and the generative and denoising power of Stable Diffusion – to better understand and process abstract sketch inputs. The goal is to improve tasks like sketch retrieval, recognition, segmentation, and correspondence by compensating for the weaknesses of individual models.
• The README emphasizes its CVPR 2025 publication, multiple evaluation benchmarks, and integration with other repositories (CLIP, DIFT, Geo-Aware). This confirms that the system is a research-oriented, experimentation-heavy full-stack model training/inference pipeline for sketch understanding.
Analyzing the File Structure
• Key top-level items: LICENSE, README.md, and setup scripts (prepare_dataset.py, setup.sh) are at the root.
• The main source code is under the src directory. Notice two main subdirectories:
– src/CLIP: Contains code for handling CLIP (e.g., clip.py, model.py, tokenizer) which supplies the semantic features.
– src/SD_CLIP: Contains training scripts (pck_train_combined.py), configuration files (configs/train_sketch.yaml), utilities, and model utilities (for resnet, projection network, and correspondence models). This part is responsible for blending SD’s capabilities with CLIP’s semantic features.
Key Architectural Components
a. Data and Configuration:
• Input data such as sketch images (datasets mentioned in the README).
• Preprocessing/utilities code (prepare_dataset.py, and utils in SD_CLIP for datasets and losses).
• YAML configuration file (train_sketch.yaml) which drives training parameters.
b. Foundation Model Modules:
• CLIP Module: Under src/CLIP/clip, responsible for tokenization and semantic feature extraction.
• Stable Diffusion (SD) Module: Implied through SD_CLIP integration (the “denoising” process) even if the actual SD network is part of a pre-trained pipeline.
• Fusion/Projection Networks: Found in src/SD_CLIP/model_utils where modules like projection_network.py and corr_map_model.py help integrate features from both modalities.
c. Training and Integration Layer:
• The training or pipeline orchestrator is found in pck_train_combined.py within SD_CLIP, which dynamically injects CLIP features into the SD denoising process.
• This part handles adaptive feature aggregation (linking to the projector networks and intermediate losses defined in utils).
d. Output/Task-Specific Modules:
• Although the code may not create distinct components for each task, the README shows outputs for segmentation, retrieval, recognition, and correspondence. Represent these as results produced by the fusion of models.
Relationships and Interactions
• Then branch out to two parallel pipelines:
• These pipelines then converge at the fusion layer (projection_network, correspondence models) where features are injected and adaptively aggregated.
Architectural Patterns/Design Principles
• Modularity by showing separable, clearly labeled modules (data, CLIP, SD, fusion, outputs).
• Integration mechanism – the injection of CLIP features into SD’s process – to point out dynamic feature fusion.
• Mention that the code builds on external projects so you may add notes or external dependency nodes (like “Based on OpenAI CLIP”, “Inspired by DIFT and Geo-Aware-SC”).
Final Advice
• Labels and annotations should explain the role of each module in a few words (for instance, “CLIP: Extracts semantic features from sketches”, “SD: Performs denoising with spatial frequency focus”, “Projection Network: Aligns and integrates features”).