Kyle Pearson commited on
Commit
556456f
·
1 Parent(s): bef445e

docs and settings

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. .gitignore +7 -0
  3. .gitmodules +3 -0
  4. README.md +149 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ test.ply filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ .DS_Store
2
+ __pycache__/
3
+ onnx__*
4
+ monodepth_*
5
+ feature_model*
6
+ _Constant_*
7
+ _init_model_*
.gitmodules ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [submodule "ml-sharp"]
2
+ path = ml-sharp
3
+ url = https://github.com/apple/ml-sharp
README.md CHANGED
@@ -1,3 +1,152 @@
1
  ---
2
  license: apple-amlr
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apple-amlr
3
+ library_name: ml-sharp
4
+ pipeline_tag: image-to-3d
5
+ base_model: apple/Sharp
6
  ---
7
+
8
+
9
+ # Sharp Monocular View Synthesis in Less Than a Second (Core ML Edition)
10
+
11
+ [![Project Page](https://img.shields.io/badge/Project-Page-green)](https://apple.github.io/ml-sharp/)
12
+ [![arXiv](https://img.shields.io/badge/arXiv-2512.10685-b31b1b.svg)](https://arxiv.org/abs/2512.10685)
13
+
14
+ > This software project accompanies the research paper: _Sharp Monocular View Synthesis in Less Than a Second_
15
+ by _Lars Mescheder, Wei Dong, Shiwei Li, Xuyang Bai, Marcel Santos, Peiyun Hu, Bruno Lecouat, Mingmin Zhen, Amaël Delaunoy, Tian Fang, Yanghai Tsin, Stephan Richter and Vladlen Koltun_.
16
+
17
+ We present SHARP, an approach to photorealistic view synthesis from a single image. Given a single photograph, SHARP regresses the parameters of a 3D Gaussian representation of the depicted scene. This is done in less than a second on a standard GPU via a single feedforward pass through a neural network. The 3D Gaussian representation produced by SHARP can then be rendered in real time, yielding high-resolution photorealistic images for nearby views. The representation is metric, with absolute scale, supporting metric camera movements.
18
+
19
+ #### ✅ **Now available natively on Apple devices** — This release includes a fully validated **Core ML (.mlpackage)** version of SHARP, optimized for CPU, GPU, and Neural Engine inference on macOS and iOS.
20
+
21
+ ![](viewer.gif)
22
+
23
+ Rendered using [Splat Viewer](https://huggingface.co/spaces/pearsonkyle/Gaussian-Splat-Viewer)
24
+
25
+ ## Getting started
26
+
27
+ ### 📦 Download the Core ML Model
28
+
29
+ Make sure `git-xet` is installed (https://hf.co/docs/hub/git-xet):
30
+
31
+ ```bash
32
+ brew install git-xet
33
+ git xet install
34
+ ```
35
+
36
+ Clone the model repository:
37
+
38
+ ```bash
39
+ git clone --recursive https://huggingface.co/pearsonkyle/Sharp-mlmodel
40
+ ```
41
+
42
+ ### 📱 Run Inference on Apple Devices
43
+
44
+ Use the provided [sharp.swift](sharp.swift) inference script to load the model and generate 3D Gaussian splats (PLY) from any image:
45
+
46
+ ```bash
47
+ # Compile the Swift runner (requires Xcode command-line tools)
48
+ swiftc -O -o run_sharp sharp.swift -framework CoreML -framework CoreImage -framework AppKit
49
+
50
+ # Run inference on an image and decimate the output by 50%
51
+ ./run_sharp sharp.mlpackage test.png test.ply -d 0.5
52
+ ```
53
+
54
+ > Inference on an Apple M4 Max takes ~1.9 seconds.
55
+
56
+ ```bash
57
+ Usage: \(execName) [OPTIONS] <model> <input_image> <output.ply>
58
+
59
+ SHARP Model Inference - Generate 3D Gaussian Splats from a single image
60
+
61
+ Arguments:
62
+ model Path to the SHARP Core ML model (.mlpackage, .mlmodel, or .mlmodelc)
63
+ input_image Path to input image (PNG, JPEG, etc.)
64
+ output.ply Path for output PLY file
65
+
66
+ Options:
67
+ -m, --model PATH Path to Core ML model
68
+ -i, --input PATH Path to input image
69
+ -o, --output PATH Path for output PLY file
70
+ -f, --focal-length FLOAT Focal length in pixels (default: 1536)
71
+ -d, --decimation FLOAT Decimation ratio 0.0-1.0 or percentage 1-100 (default: 1.0 = keep all)
72
+ Example: 0.5 or 50 keeps 50% of Gaussians
73
+ -h, --help Show this help message
74
+ ```
75
+
76
+ **CLI Features:**
77
+ - Automatic model compilation and caching
78
+ - Decimation to reduce point cloud size while preserving visual fidelity
79
+ - Input is expected as a standard RGB image; conversion to [0,1] and CHW format happens inside the model
80
+ - PLY output compatible with [Splat Viewer](https://huggingface.co/spaces/pearsonkyle/Gaussian-Splat-Viewer), [MetalSplatter](https://github.com/scier/MetalSplatter), and [Three.js](https://threejs.org)
81
+
82
+ ## Model Input and Output
83
+
84
+ ### 📥 Input
85
+ The Core ML model accepts two inputs:
86
+
87
+ - **`image`**: A 3-channel RGB image in `uint8` format with shape `(1, 3, H, W)`.
88
+ - Values are expected in range `[0, 255]` (no manual normalization required).
89
+ - Recommended resolution: `1536×1536` (matches training size).
90
+ - Aspect ratio is preserved; input will be resized internally if needed.
91
+
92
+ - **`disparity_factor`**: A scalar tensor of shape `(1,)` representing the ratio `focal_length / image_width`.
93
+ - Use `1.0` for standard cameras (e.g., typical smartphone or DSLR).
94
+ - Adjust slightly to control depth scale: higher values = closer objects, lower values = farther scenes.
95
+ - If using the `sharp.swift` runner, this input is automatically computed from your image dimensions.
96
+
97
+ ### 📤 Output
98
+ The model outputs five tensors representing a 3D Gaussian splat representation:
99
+
100
+ | Output | Shape | Description |
101
+ |--------|-------|-------------|
102
+ | `mean_vectors_3d_positions` | `(1, N, 3)` | 3D positions in Normalized Device Coordinates (NDC) — x, y, z. |
103
+ | `singular_values_scales` | `(1, N, 3)` | Scale parameters along each principal axis (width, height, depth). |
104
+ | `quaternions_rotations` | `(1, N, 4)` | Unit quaternions `[w, x, y, z]` encoding orientation of each Gaussian. |
105
+ | `colors_rgb_linear` | `(1, N, 3)` | Linear RGB color values in range `[0, 1]` (no gamma correction). |
106
+ | `opacities_alpha_channel` | `(1, N)` | Opacity (alpha) values per Gaussian, in range `[0, 1]`. |
107
+
108
+ > ✅ These outputs are fully compatible with [Splat Viewer](https://huggingface.co/spaces/pearsonkyle/Gaussian-Splat-Viewer) and [MetalSplatter](https://github.com/scier/MetalSplatter).
109
+
110
+ The total number of Gaussians `N` is approximately 1,179,648 for the default model.
111
+
112
+ ### 🔍 Model Validation Results
113
+
114
+ The Core ML model has been rigorously validated against the original PyTorch implementation. Below are the numerical accuracy metrics across all 5 output tensors:
115
+
116
+ | Output | Max Diff | Mean Diff | P99 Diff | Angular Diff (°) | Status |
117
+ |--------|----------|-----------|----------|------------------|--------|
118
+ | Mean Vectors (3D Positions) | 0.000794 | 0.000049 | 0.000094 | - | ✅ PASS |
119
+ | Singular Values (Scales) | 0.000035 | 0.000000 | 0.000002 | - | ✅ PASS |
120
+ | Quaternions (Rotations) | 1.425558 | 0.000024 | 0.000067 | 9.2519 / 0.0019 / 0.0396 | ✅ PASS |
121
+ | Colors (RGB Linear) | 0.001440 | 0.000005 | 0.000055 | - | ✅ PASS |
122
+ | Opacities (Alpha) | 0.004183 | 0.000005 | 0.000114 | - | ✅ PASS |
123
+
124
+ > **Validation Notes:**
125
+ > - All outputs match PyTorch within 0.01% mean error.
126
+ > - Quaternion angular errors are below 1° for 99% of Gaussians.
127
+
128
+ ## Reproducing the Conversion
129
+
130
+ To reproduce the conversion from PyTorch to Core ML, follow these steps:
131
+ ```
132
+ conda create -n sharp python=3.13
133
+ conda activate sharp
134
+ pip install -r ml-sharp/requirements.txt
135
+ pip install coremltools
136
+ python convert.py
137
+ ```
138
+
139
+ ## Citation
140
+
141
+ If you find this work useful, please cite the original paper:
142
+
143
+ ```bibtex
144
+ @inproceedings{Sharp2025:arxiv,
145
+ title = {Sharp Monocular View Synthesis in Less Than a Second},
146
+ author = {Lars Mescheder and Wei Dong and Shiwei Li and Xuyang Bai and Marcel Santos and Peiyun Hu and Bruno Lecouat and Mingmin Zhen and Ama\"{e}l Delaunoy and Tian Fang and Yanghai Tsin and Stephan R. Richter and Vladlen Koltun},
147
+ journal = {arXiv preprint arXiv:2512.10685},
148
+ year = {2025},
149
+ url = {https://arxiv.org/abs/2512.10685},
150
+ }
151
+ ```
152
+