How amirhertz/spaghetti works
File Structure Analysis
Top-level scripts and files
• demo.py – Entry point that launches the GUI and ties it to model inference
• download_weights.py – Fetches pre‐trained model checkpoints
• options.py – CLI argument parsing and configuration definitions
• environment.yml – Specifies conda environment and dependencies
Directories
• models/ – Model definitions (MLP, transformer, OCC GMM, losses, utilities)
• ui/ – All GUI code: main window, controllers, interactors, status bar, inference bridge
• utils/ – Shared utilities: file I/O, meshing (mcubes), mesh transforms, CLI parsing, training helpers
Key Architectural Insights from README
• The demo loads pre‐trained weights, presents a mesh collection at the bottom panel, and lets users select mesh parts and apply transformations (G, R, X/Y/Z axes).
• The core inference cycle: UI events → ui/inference_processing → ui/occ_inference → models → utils/meshing → display.
Main Components
• ui/ui_main.py – Bootstraps the Qt/OpenGL window
• ui/ui_controllers.py – Handles user input, toolbar actions
• ui/interactors.py – Maps keyboard/mouse events to GUI operations
• ui/gaussian_status.py – Displays mixture status and editing tools
• ui/inference_processing.py & occ_inference.py – Converts GUI state into model inference calls
• models/transformer.py – Neural network blocks for part generation
• models/mlp_models.py – MLP backbones for occupancy prediction
• models/occ_loss.py – Loss functions (used for inversion/training)
• models/models_utils.py, gm_utils.py – Model-specific utility routines
• assets/mesh/*.obj – Sample meshes
• samples/ (runtime directory) – Inference output
• download_weights.py – Populates weights/ directory
• utils/files_utils.py – Disk I/O and path management
• utils/mcubes_meshing.py – Marching cubes to turn occupancy grid into mesh
• utils/mesh_utils.py – Mesh transformations and cleanup
• utils/rotation_utils.py – Quaternion / Euler conversions
• utils/train_utils.py – Training loop helpers (future use)
• utils/myparse.py – CLI parsing support
Relationships and Data Flow
• demo.py initializes the UI layer and calls download_weights if needed.
• User selects a mesh → ui_controllers triggers inference_processing.
• inference_processing calls occ_inference, which loads the model weights and invokes the Model Inference Layer to predict occupancy or part latent codes.
• The resulting occupancy grid is sent to utils/mcubes_meshing, converted into a displayable mesh, and fed back to the UI for rendering.
• shape_inversion.py is a separate CLI tool: it uses options.py → models + utils → writes to samples/ for later demo loading.
Architectural Patterns & Design Principles
• Clear separation of concerns: GUI vs ML inference vs utilities.
• Modular model definitions: each model type and loss function lives in its own file.
• Script-based orchestration: demo.py and shape_inversion.py serve as “application” entry points, loading configuration and wiring modules together.
• Event-driven UI → inference calls → render cycle for interactive performance.
Detail
• How environment.yml captures all dependencies for reproducibility.