Upload LoRA adapter — DIODE Indoors
Browse files- README.md +71 -0
- adapter_config.json +44 -0
- adapter_model.safetensors +3 -0
README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: peft
|
| 3 |
+
tags:
|
| 4 |
+
- depth-estimation
|
| 5 |
+
- lora
|
| 6 |
+
- peft
|
| 7 |
+
- metric3d
|
| 8 |
+
- diode
|
| 9 |
+
- indoor
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# Metric3D ViT-giant2 — LoRA adapter (DIODE Indoors)
|
| 14 |
+
|
| 15 |
+
> **Base model:** [`metric3d_vit_giant2`](https://github.com/YvanYin/Metric3D)
|
| 16 |
+
> loaded via `torch.hub.load("yvanyin/metric3d", "metric3d_vit_giant2")`
|
| 17 |
+
|
| 18 |
+
LoRA fine-tuning of [Metric3D v2](https://github.com/YvanYin/Metric3D)
|
| 19 |
+
(`metric3d_vit_giant2`) on the [DIODE](https://diode-dataset.org/) indoor split (metric depth in metres).
|
| 20 |
+
|
| 21 |
+
## Training details
|
| 22 |
+
|
| 23 |
+
| | |
|
| 24 |
+
|---|---|
|
| 25 |
+
| Base model | `metric3d_vit_giant2` (torch.hub `yvanyin/metric3d`) |
|
| 26 |
+
| Dataset | the [DIODE](https://diode-dataset.org/) indoor split (metric depth in metres) |
|
| 27 |
+
| Loss | Direct metric-depth L1 + gradient loss |
|
| 28 |
+
| LoRA rank / alpha | 16 / 32 |
|
| 29 |
+
| LoRA targets | `qkv`, `proj` |
|
| 30 |
+
|
| 31 |
+
## Usage
|
| 32 |
+
|
| 33 |
+
```python
|
| 34 |
+
import torch
|
| 35 |
+
from peft import PeftModel
|
| 36 |
+
import torch.nn as nn
|
| 37 |
+
import torch.utils.checkpoint as torch_checkpoint
|
| 38 |
+
|
| 39 |
+
# Load base model
|
| 40 |
+
model = torch.hub.load("yvanyin/metric3d", "metric3d_vit_giant2",
|
| 41 |
+
pretrain=True, trust_repo=True)
|
| 42 |
+
|
| 43 |
+
# Apply the same gradient-checkpointing wrapper used during training
|
| 44 |
+
# (needed so PEFT key names match the saved adapter)
|
| 45 |
+
def enable_gradient_checkpointing(model):
|
| 46 |
+
try:
|
| 47 |
+
encoder = model.depth_model.encoder
|
| 48 |
+
except AttributeError:
|
| 49 |
+
encoder = model.base_model.model.depth_model.encoder
|
| 50 |
+
|
| 51 |
+
class _CheckpointedBlock(nn.Module):
|
| 52 |
+
def __init__(self, block):
|
| 53 |
+
super().__init__()
|
| 54 |
+
self.block = block
|
| 55 |
+
def forward(self, x):
|
| 56 |
+
return torch_checkpoint.checkpoint(self.block, x, use_reentrant=False)
|
| 57 |
+
|
| 58 |
+
for blk_group in encoder.blocks:
|
| 59 |
+
for key in list(blk_group._modules.keys()):
|
| 60 |
+
blk_group._modules[key] = _CheckpointedBlock(blk_group._modules[key])
|
| 61 |
+
|
| 62 |
+
enable_gradient_checkpointing(model)
|
| 63 |
+
model = PeftModel.from_pretrained(model, "igzi/depth-lora-checkpoints_diode-diode_indoors")
|
| 64 |
+
model.eval()
|
| 65 |
+
|
| 66 |
+
# Inference: input pixel_values shape (B, 3, 616, 1064), values normalised
|
| 67 |
+
# with mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375]
|
| 68 |
+
pred_canonical, _, _ = model({"input": pixel_values})
|
| 69 |
+
# De-canonicalise: pred_metric = pred_canonical * (fx_scaled / 1000)
|
| 70 |
+
```
|
| 71 |
+
|
adapter_config.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"alora_invocation_tokens": null,
|
| 3 |
+
"alpha_pattern": {},
|
| 4 |
+
"arrow_config": null,
|
| 5 |
+
"auto_mapping": {
|
| 6 |
+
"base_model_class": "DepthModel",
|
| 7 |
+
"parent_library": "mono.model.monodepth_model"
|
| 8 |
+
},
|
| 9 |
+
"base_model_name_or_path": null,
|
| 10 |
+
"bias": "none",
|
| 11 |
+
"corda_config": null,
|
| 12 |
+
"ensure_weight_tying": false,
|
| 13 |
+
"eva_config": null,
|
| 14 |
+
"exclude_modules": null,
|
| 15 |
+
"fan_in_fan_out": false,
|
| 16 |
+
"inference_mode": true,
|
| 17 |
+
"init_lora_weights": true,
|
| 18 |
+
"layer_replication": null,
|
| 19 |
+
"layers_pattern": null,
|
| 20 |
+
"layers_to_transform": null,
|
| 21 |
+
"loftq_config": {},
|
| 22 |
+
"lora_alpha": 32,
|
| 23 |
+
"lora_bias": false,
|
| 24 |
+
"lora_dropout": 0.05,
|
| 25 |
+
"megatron_config": null,
|
| 26 |
+
"megatron_core": "megatron.core",
|
| 27 |
+
"modules_to_save": null,
|
| 28 |
+
"peft_type": "LORA",
|
| 29 |
+
"peft_version": "0.18.1",
|
| 30 |
+
"qalora_group_size": 16,
|
| 31 |
+
"r": 16,
|
| 32 |
+
"rank_pattern": {},
|
| 33 |
+
"revision": null,
|
| 34 |
+
"target_modules": [
|
| 35 |
+
"qkv",
|
| 36 |
+
"proj"
|
| 37 |
+
],
|
| 38 |
+
"target_parameters": null,
|
| 39 |
+
"task_type": null,
|
| 40 |
+
"trainable_token_indices": null,
|
| 41 |
+
"use_dora": false,
|
| 42 |
+
"use_qalora": false,
|
| 43 |
+
"use_rslora": false
|
| 44 |
+
}
|
adapter_model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3b126cc053e0cfbe858bd69f34bbf0db0cc7362a1c24324cf610a89811cb26d5
|
| 3 |
+
size 23752944
|