Datasets:
Improve dataset card: add metadata, links, and usage snippet
#3
by
nielsr
HF Staff
- opened
README.md
CHANGED
|
@@ -1,6 +1,102 @@
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
| 4 |
-
This Dataset contains the training data for the paper [Orient Anything V2: Unifying Orientation and Rotation Understanding](https://huggingface.co/papers/2601.05573).
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- other
|
| 5 |
+
tags:
|
| 6 |
+
- 3d
|
| 7 |
+
- computer-vision
|
| 8 |
+
- orientation-estimation
|
| 9 |
---
|
|
|
|
| 10 |
|
| 11 |
+
# Orient Anything V2 Dataset
|
| 12 |
+
|
| 13 |
+
[**Project Page**](https://orient-anythingv2.github.io/) | [**Paper**](https://huggingface.co/papers/2601.05573) | [**GitHub**](https://github.com/SpatialVision/Orient-Anything-V2)
|
| 14 |
+
|
| 15 |
+
**Orient Anything V2** is an enhanced foundation model for unified understanding of object 3D orientation and rotation from single or paired images. This repository contains the training data (final rendering data) used for the model.
|
| 16 |
+
|
| 17 |
+
## Sample Usage
|
| 18 |
+
|
| 19 |
+
Below is a snippet to run inference using the model and data logic, as found in the [official GitHub repository](https://github.com/SpatialVision/Orient-Anything-V2):
|
| 20 |
+
|
| 21 |
+
```python
|
| 22 |
+
import numpy as np
|
| 23 |
+
from PIL import Image
|
| 24 |
+
import torch
|
| 25 |
+
import tempfile
|
| 26 |
+
import os
|
| 27 |
+
|
| 28 |
+
from paths import *
|
| 29 |
+
from vision_tower import VGGT_OriAny_Ref
|
| 30 |
+
from inference import *
|
| 31 |
+
from app_utils import *
|
| 32 |
+
|
| 33 |
+
mark_dtype = torch.bfloat16 if torch.cuda.get_device_capability()[0] >= 8 else torch.float16
|
| 34 |
+
# device = 'cuda:0'
|
| 35 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 36 |
+
|
| 37 |
+
if os.path.exists(LOCAL_CKPT_PATH):
|
| 38 |
+
ckpt_path = LOCAL_CKPT_PATH
|
| 39 |
+
else:
|
| 40 |
+
from huggingface_hub import hf_hub_download
|
| 41 |
+
ckpt_path = hf_hub_download(repo_id="Viglong/Orient-Anything-V2", filename=HF_CKPT_PATH, repo_type="model", cache_dir='./', resume_download=True)
|
| 42 |
+
|
| 43 |
+
model = VGGT_OriAny_Ref(out_dim=900, dtype=mark_dtype, nopretrain=True)
|
| 44 |
+
model.load_state_dict(torch.load(ckpt_path, map_location='cpu'))
|
| 45 |
+
model.eval()
|
| 46 |
+
model = model.to(device)
|
| 47 |
+
print('Model loaded.')
|
| 48 |
+
|
| 49 |
+
@torch.no_grad()
|
| 50 |
+
def run_inference(pil_ref, pil_tgt=None, do_rm_bkg=True):
|
| 51 |
+
if pil_tgt is not None:
|
| 52 |
+
if do_rm_bkg:
|
| 53 |
+
pil_ref = background_preprocess(pil_ref, True)
|
| 54 |
+
pil_tgt = background_preprocess(pil_tgt, True)
|
| 55 |
+
else:
|
| 56 |
+
if do_rm_bkg:
|
| 57 |
+
pil_ref = background_preprocess(pil_ref, True)
|
| 58 |
+
|
| 59 |
+
try:
|
| 60 |
+
ans_dict = inf_single_case(model, pil_ref, pil_tgt)
|
| 61 |
+
except Exception as e:
|
| 62 |
+
print("Inference error:", e)
|
| 63 |
+
raise gr.Error(f"Inference failed: {str(e)}")
|
| 64 |
+
|
| 65 |
+
def safe_float(val, default=0.0):
|
| 66 |
+
try:
|
| 67 |
+
return float(val)
|
| 68 |
+
except:
|
| 69 |
+
return float(default)
|
| 70 |
+
|
| 71 |
+
az = safe_float(ans_dict.get('ref_az_pred', 0))
|
| 72 |
+
el = safe_float(ans_dict.get('ref_el_pred', 0))
|
| 73 |
+
ro = safe_float(ans_dict.get('ref_ro_pred', 0))
|
| 74 |
+
alpha = int(ans_dict.get('ref_alpha_pred', 1))
|
| 75 |
+
|
| 76 |
+
if pil_tgt is not None:
|
| 77 |
+
rel_az = safe_float(ans_dict.get('rel_az_pred', 0))
|
| 78 |
+
rel_el = safe_float(ans_dict.get('rel_el_pred', 0))
|
| 79 |
+
rel_ro = safe_float(ans_dict.get('rel_ro_pred', 0))
|
| 80 |
+
|
| 81 |
+
print("Relative Pose: Azi",rel_az,"Ele",rel_el,"Rot",rel_ro)
|
| 82 |
+
|
| 83 |
+
image_ref_path = 'assets/examples/F35-0.jpg'
|
| 84 |
+
image_tgt_path = 'assets/examples/F35-1.jpg' # optional
|
| 85 |
+
|
| 86 |
+
image_ref = Image.open(image_ref_path).convert('RGB')
|
| 87 |
+
image_tgt = Image.open(image_tgt_path).convert('RGB')
|
| 88 |
+
|
| 89 |
+
run_inference(image_ref, image_tgt, True)
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## Citation
|
| 93 |
+
|
| 94 |
+
If you find this project useful, please consider citing:
|
| 95 |
+
|
| 96 |
+
```bibtex
|
| 97 |
+
@inproceedings{wangorient,
|
| 98 |
+
title={Orient Anything V2: Unifying Orientation and Rotation Understanding},
|
| 99 |
+
author={Wang, Zehan and Zhang, Ziang and Xu, Jiayang and Wang, Jialei and Pang, Tianyu and Du, Chao and Zhao, Hengshuang and Zhao, Zhou},
|
| 100 |
+
booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems}
|
| 101 |
+
}
|
| 102 |
+
```
|