mlboydaisuke commited on
Commit
b646201
·
verified ·
1 Parent(s): e921d8f

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +83 -0
README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ library_name: litert
4
+ pipeline_tag: depth-estimation
5
+ base_model: Ruicheng/moge-2-vits-normal
6
+ tags:
7
+ - litert
8
+ - tflite
9
+ - on-device
10
+ - android
11
+ - monocular-geometry
12
+ - depth-estimation
13
+ - surface-normals
14
+ - point-cloud
15
+ - dinov2
16
+ ---
17
+
18
+ # MoGe-2 ViT-S — LiteRT (TFLite) GPU
19
+
20
+ On-device [LiteRT](https://ai.google.dev/edge/litert) (`.tflite`) conversion of
21
+ **[MoGe-2](https://github.com/microsoft/MoGe)** (CVPR'25 Oral) monocular geometry
22
+ estimation, converted from [`Ruicheng/moge-2-vits-normal`](https://huggingface.co/Ruicheng/moge-2-vits-normal)
23
+ (DINOv2 ViT-S backbone, 35M params).
24
+
25
+ A single forward pass turns one RGB image into an **affine 3D point map**,
26
+ **surface normals**, a **confidence mask**, and a **metric scale** — enabling
27
+ depth, surface normals, and a rotatable 3D point cloud on a phone.
28
+
29
+ The model runs **fully on the LiteRT `CompiledModel` GPU accelerator** (ML Drift):
30
+ all 836 ops are GPU-native, no CPU fallback, no Flex ops.
31
+
32
+ ## Files
33
+
34
+ | File | Size | Description |
35
+ |------|------|-------------|
36
+ | `moge.tflite` | 136 MB | FP32 single-graph model, GPU-compatible |
37
+
38
+ ## I/O
39
+
40
+ - **Input**: `[1, 3, 448, 448]` float32, **NCHW**, RGB normalized to `[0, 1]`
41
+ (ImageNet mean/std is applied *inside* the graph).
42
+ - **Outputs** (4):
43
+ - `points` `[1, 448, 448, 3]` — affine point map (`exp` remap: `[xy·exp(z), exp(z)]`)
44
+ - `normal` `[1, 448, 448, 3]` — L2-normalized surface normals
45
+ - `mask` `[1, 448, 448, 1]` — sigmoid confidence (> 0.5 = valid)
46
+ - `scale` `[1, 1, 1, 1]` — metric scale factor
47
+
48
+ ## Usage (Android, LiteRT CompiledModel)
49
+
50
+ ```kotlin
51
+ val model = CompiledModel.create(
52
+ context.assets, "moge.tflite",
53
+ CompiledModel.Options(Accelerator.GPU), null
54
+ )
55
+ val inputs = model.createInputBuffers()
56
+ val outputs = model.createOutputBuffers()
57
+ inputs[0].writeFloat(nchwFloatArray) // [1,3,448,448], RGB [0,1]
58
+ model.run(inputs, outputs)
59
+ val points = outputs[0].readFloat() // identify the 4 outputs by element count + range
60
+ ```
61
+
62
+ A complete Android sample (gallery → normal map + depth) is available in
63
+ [google-ai-edge/litert-samples](https://github.com/google-ai-edge/litert-samples).
64
+
65
+ ## Performance
66
+
67
+ - ~522 ms / frame on a Pixel 8a (Mali-G615) GPU.
68
+
69
+ ## Conversion notes
70
+
71
+ Converted with [litert-torch](https://github.com/google-ai-edge/ai-edge-torch)
72
+ (NCHW preserved — required for ViT attention accuracy). Making DINOv2 + the
73
+ ConvStack decoder fully GPU-compatible required nine graph rewrites
74
+ (LayerScale bake, fused-qkv decomposition, position-embedding bake,
75
+ ConvTranspose → bilinear+1×1, etc.). Verified: all ops GPU-native, output
76
+ correlation ≈ 1.0 vs. the PyTorch reference.
77
+
78
+ ## License & attribution
79
+
80
+ - Model: **MIT** (original [microsoft/MoGe](https://github.com/microsoft/MoGe/blob/main/LICENSE)).
81
+ - DINOv2 backbone components: Apache-2.0.
82
+ - This is a format conversion of `Ruicheng/moge-2-vits-normal`; all credit to the
83
+ original authors (Microsoft Research).