# adhithiya42/enhanced_pugeonet architecture

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

- Interactive diagram: https://gitdiagram.com/adhithiya42/enhanced_pugeonet
- Repository: https://github.com/adhithiya42/enhanced_pugeonet

## Overview

#### Purpose and entry points
PUGeo-Net Enhanced is a script-driven point-cloud upsampling demo focused on curved and hollow surfaces. Its primary entry points are `pugeonet_enhanced/scripts/run_pipeline.py` for the end-to-end workflow and `pugeonet_enhanced/scripts/multi_rate_comparison.py` for comparing output across upsampling factors.

#### Input geometry and sampling
Synthetic stress-test geometries—torus, sphere, hollow cylinder, and saddle—are generated in `pugeonet_enhanced/src/shapes.py`. `pugeonet_enhanced/src/curvature_sampling.py` estimates local curvature and performs curvature-aware farthest-point sampling, biasing sparse input points toward high-curvature regions before inference.

#### Neural upsampling model
`pugeonet_enhanced/src/model.py` contains `EnhancedPUGeoNet`, the central PyTorch model. The architecture uses adaptive neighborhood sizing, PCA-derived tangent frames, curvature-scaled seed offsets, tangent-projected displacement, and normal prediction. Its loss design combines geometric reconstruction with normal consistency and repulsion, targeting surface fidelity and prevention of hollow-shell leakage.

#### Inference and model initialization
Forward-pass orchestration is isolated in `pugeonet_enhanced/src/inference.py`. `pugeonet_enhanced/src/pretrained.py` optionally downloads and loads baseline PUGeo-Net weights; the pipeline remains runnable with freshly initialized weights when retrieval fails or is skipped. Runtime/device and sample-rate defaults are centralized in `pugeonet_enhanced/src/config.py`.

#### Surface correction and evaluation
Raw predicted points cross a post-inference boundary into `pugeonet_enhanced/src/postprocess.py`, where shell projection uses nearest-surface/KD-tree logic to correct interior drift on hollow objects. `pugeonet_enhanced/src/metrics.py` then evaluates reconstructed clouds with Chamfer distance, Hausdorff distance, and normal consistency metrics.

#### Outputs and visualization boundary
The pipeline writes point clouds through `pugeonet_enhanced/src/io_utils.py` and produces static figures via `pugeonet_enhanced/src/visualization.py`. Optional interactive inspection is separated into `pugeonet_enhanced/src/interactive_viz.py`, using Open3D and Plotly; CLI flags permit headless execution. Outputs are directed to the configured relative output location, normally `./output_enhanced/`.

#### Runtime and external dependencies
The core runtime is Python with PyTorch, using CPU by default and optionally CUDA-compatible PyTorch. The project relies on scientific point-cloud operations plus KD-tree-based postprocessing, matplotlib for static artifacts, Open3D for desktop interaction, Plotly for browser-capable figures, and external checkpoint hosting accessed by `pugeonet_enhanced/src/pretrained.py`.

Main entry points: [`pugeonet_enhanced/scripts/run_pipeline.py`](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/scripts/run_pipeline.py) (End-to-end pipeline), [`pugeonet_enhanced/src/postprocess.py`](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/postprocess.py) (Shell projection), [`pugeonet_enhanced/src/model.py`](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/model.py) (EnhancedPUGeoNet), [`pugeonet_enhanced/src/shapes.py`](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/shapes.py) (Stress-test shapes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Workflow entry points"]
  node_pipeline["End-to-end pipeline<br/>Python CLI<br/>[run_pipeline.py]"]
  node_comparison["Multi-rate comparison<br/>Python CLI"]
  node_config["Runtime defaults<br/>configuration module<br/>[config.py]"]
end

subgraph group_data["Geometry and sampling"]
  node_shapes["Stress-test shapes<br/>synthetic geometry<br/>[shapes.py]"]
  node_sampling["Curvature-aware sampling<br/>point sampler"]
end

subgraph group_inference["Upsampling runtime"]
  node_pretrained["Checkpoint loader<br/>model initialization<br/>[pretrained.py]"]
  node_checkpoint_host(("External checkpoint hosting<br/>external service"))
  node_inference_runner["Forward-pass orchestration<br/>inference module<br/>[inference.py]"]
  node_model["EnhancedPUGeoNet<br/>PyTorch model<br/>[model.py]"]
  node_surface_aware_layers["Surface-aware upsampling<br/>model architecture<br/>[model.py]"]
  node_pytorch{{"PyTorch runtime<br/>compute runtime"}}
end

subgraph group_output["Correction and outputs"]
  node_postprocess["Shell projection<br/>post-inference correction<br/>[postprocess.py]"]
  node_metrics["Reconstruction metrics<br/>evaluation module<br/>[metrics.py]"]
  node_io["Point-cloud export<br/>output writer<br/>[io_utils.py]"]
  node_static_viz["Static visualization<br/>figure renderer<br/>[visualization.py]"]
  node_interactive_viz["Interactive inspection<br/>optional viewer<br/>[interactive_viz.py]"]
  node_output_dir["Output artifacts<br/>output directory"]
end

node_pipeline -->|"reads defaults"| node_config
node_pipeline -->|"generates source cloud"| node_shapes
node_shapes -->|"dense geometry"| node_sampling
node_sampling -->|"sparse input cloud"| node_inference_runner
node_pipeline -->|"initializes model"| node_pretrained
node_pretrained -.->|"optional download"| node_checkpoint_host
node_pretrained -.->|"loads weights when available"| node_model
node_inference_runner -->|"executes forward pass"| node_model
node_model -->|"implements"| node_surface_aware_layers
node_model -->|"runs on"| node_pytorch
node_inference_runner -->|"raw predicted points"| node_postprocess
node_postprocess -->|"corrected cloud"| node_metrics
node_shapes -->|"reference surface"| node_metrics
node_postprocess -->|"final cloud"| node_io
node_io -->|"writes point clouds"| node_output_dir
node_postprocess -->|"visualizes result"| node_static_viz
node_static_viz -->|"writes figures"| node_output_dir
node_pipeline -.->|"optional CLI path"| node_interactive_viz
node_interactive_viz -.->|"writes interactive artifacts"| node_output_dir
node_comparison -->|"varies upsampling rate"| node_pipeline

click node_pipeline "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/scripts/run_pipeline.py"
click node_comparison "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/scripts/multi_rate_comparison.py"
click node_config "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/config.py"
click node_shapes "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/shapes.py"
click node_sampling "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/curvature_sampling.py"
click node_pretrained "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/pretrained.py"
click node_inference_runner "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/inference.py"
click node_model "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/model.py"
click node_surface_aware_layers "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/model.py"
click node_postprocess "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/postprocess.py"
click node_metrics "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/metrics.py"
click node_io "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/io_utils.py"
click node_static_viz "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/visualization.py"
click node_interactive_viz "https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/interactive_viz.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pipeline,node_comparison,node_config toneBlue
class node_shapes,node_sampling toneAmber
class node_pretrained,node_checkpoint_host,node_inference_runner,node_model,node_surface_aware_layers,node_pytorch toneMint
class node_postprocess,node_metrics,node_io,node_static_viz,node_interactive_viz,node_output_dir toneRose
```

## Components

### Workflow entry points

- [End-to-end pipeline](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/scripts/run_pipeline.py): Python CLI · Runs generation, sampling, inference, correction, evaluation, and export. · `pugeonet_enhanced/scripts/run_pipeline.py`
- [Multi-rate comparison](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/scripts/multi_rate_comparison.py): Python CLI · Compares outputs across upsampling factors. · `pugeonet_enhanced/scripts/multi_rate_comparison.py`
- [Runtime defaults](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/config.py): configuration module · Centralizes device and sample-rate defaults. · `pugeonet_enhanced/src/config.py`

### Geometry and sampling

- [Stress-test shapes](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/shapes.py): synthetic geometry · Generates torus, sphere, hollow cylinder, and saddle clouds. · `pugeonet_enhanced/src/shapes.py`
- [Curvature-aware sampling](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/curvature_sampling.py): point sampler · Uses local curvature and farthest-point sampling to form sparse inputs. · `pugeonet_enhanced/src/curvature_sampling.py`

### Upsampling runtime

- [Checkpoint loader](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/pretrained.py): model initialization · Optionally retrieves and loads baseline PUGeo-Net weights. · `pugeonet_enhanced/src/pretrained.py`
- **External checkpoint hosting**: external service
- [Forward-pass orchestration](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/inference.py): inference module · `pugeonet_enhanced/src/inference.py`
- [EnhancedPUGeoNet](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/model.py): PyTorch model · Produces dense points and normals from sparse point clouds. · `pugeonet_enhanced/src/model.py`
- [Surface-aware upsampling](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/model.py): model architecture · Adaptive neighborhoods, PCA tangent frames, curvature-scaled seeds, and tangent-projected displacement. · `pugeonet_enhanced/src/model.py`
- **PyTorch runtime**: compute runtime · CPU by default with optional CUDA execution.

### Correction and outputs

- [Shell projection](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/postprocess.py): post-inference correction · Corrects interior drift using nearest-surface and KD-tree logic. · `pugeonet_enhanced/src/postprocess.py`
- [Reconstruction metrics](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/metrics.py): evaluation module · Computes Chamfer, Hausdorff, and normal consistency metrics. · `pugeonet_enhanced/src/metrics.py`
- [Point-cloud export](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/io_utils.py): output writer · `pugeonet_enhanced/src/io_utils.py`
- [Static visualization](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/visualization.py): figure renderer · Creates matplotlib artifacts. · `pugeonet_enhanced/src/visualization.py`
- [Interactive inspection](https://github.com/adhithiya42/enhanced_pugeonet/blob/main/pugeonet_enhanced/src/interactive_viz.py): optional viewer · Uses Open3D and Plotly when enabled by CLI flags. · `pugeonet_enhanced/src/interactive_viz.py`
- **Output artifacts**: output directory · Normally written under ./output_enhanced/.

## Connections

- End-to-end pipeline → Runtime defaults: reads defaults
- End-to-end pipeline → Stress-test shapes: generates source cloud
- Stress-test shapes → Curvature-aware sampling: dense geometry
- Curvature-aware sampling → Forward-pass orchestration: sparse input cloud
- End-to-end pipeline → Checkpoint loader: initializes model
- Checkpoint loader → External checkpoint hosting: optional download
- Checkpoint loader → EnhancedPUGeoNet: loads weights when available
- Forward-pass orchestration → EnhancedPUGeoNet: executes forward pass
- EnhancedPUGeoNet → Surface-aware upsampling: implements
- EnhancedPUGeoNet → PyTorch runtime: runs on
- Forward-pass orchestration → Shell projection: raw predicted points
- Shell projection → Reconstruction metrics: corrected cloud
- Stress-test shapes → Reconstruction metrics: reference surface
- Shell projection → Point-cloud export: final cloud
- Point-cloud export → Output artifacts: writes point clouds
- Shell projection → Static visualization: visualizes result
- Static visualization → Output artifacts: writes figures
- End-to-end pipeline → Interactive inspection: optional CLI path
- Interactive inspection → Output artifacts: writes interactive artifacts
- Multi-rate comparison → End-to-end pipeline: varies upsampling rate
