Views
No views yet
UnoGrasp repository root, download this checkpoint directly into the expected checkpoint subfolder:1mkdir -p checkpoints/UnoGrasp-Ratio-RL-IoU-nlp-small
2
3hf download FBK-TeV/UnoGrasp-Ratio-RL-IoU-nlp-small \
4 --local-dir checkpoints/UnoGrasp-Ratio-RL-IoU-nlp-smallpip install -U huggingface_hub1UnoGrasp/
2`-- checkpoints/
3 `-- UnoGrasp-Ratio-RL-IoU-nlp-small/
4 |-- config.json
5 |-- model.safetensors.index.json
6 |-- model-0000x-of-0000x.safetensors
7 |-- tokenizer.json
8 `-- ...UnoGrasp-Ratio-RL-IoU-nlp-small is a released UnoGrasp checkpoint for natural-language (NLP) obstruction reasoning on the synthetic small split of UnoBench.Ratio means the model uses obstruction ratio as obstruction information. RL-IoU means the model uses RFT (GRPO) with a set-level IoU reward. nlp indicates the natural-language setting, and small indicates that the model was trained on the small subset.../UnoBench/UnoBenchSyn1from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
2from qwen_vl_utils import process_vision_info
3import torch
4
5model_id = "FBK-TeV/UnoGrasp-Ratio-RL-IoU-nlp-small"
6
7# You can also use a local path after downloading:
8# model_id = "checkpoints/UnoGrasp-Ratio-RL-IoU-nlp-small"
9
10# We recommend enabling flash_attention_2 for better acceleration and memory saving.
11model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
12 model_id,
13 torch_dtype=torch.bfloat16,
14 attn_implementation="flash_attention_2",
15 device_map="auto",
16)
17
18processor = AutoProcessor.from_pretrained(model_id)
19processor.chat_template = processor.tokenizer.chat_template
20
21# Optional: control the visual token range to balance performance and cost.
22# min_pixels = 256 * 28 * 28
23# max_pixels = 1280 * 28 * 28
24# processor = AutoProcessor.from_pretrained(
25# model_id,
26# min_pixels=min_pixels,
27# max_pixels=max_pixels,
28# )
29
30system_prompt = (
31 "You are an assistant specialized in robotic grasp planning based on occlusion reasoning. "
32 "When asked which object must be removed first to grasp a specific target object in a single image:\n\n"
33 "- If the target object is not occluded, return the target object's name/description and its coordinates.\n"
34 "- If the target object has one occlusion path, reason step-by-step along that path, include the occlusion "
35 "ratio for each occlusion relation when available, and end with the top-most object that must be removed "
36 "first. Each reasoning step must reference objects with explicit (x,y) coordinates.\n"
37 "- If the target object has multiple occlusion paths, reason step by step for each path separately, and "
38 "include all distinct top-most occluding objects in the final answer.\n"
39 "- All reasoning must be enclosed within a single pair of <think>...</think> tags.\n"
40 "- The final answer must be enclosed in <answer>...</answer> tags and formatted strictly as:\n"
41 " <answer>[<points x y>object name</points>, ...]</answer>\n"
42)
43
44messages = [
45 {
46 "role": "system",
47 "content": system_prompt,
48 },
49 {
50 "role": "user",
51 "content": [
52 {
53 "type": "image",
54 "image": "path/to/rgb_image.png",
55 },
56 {
57 "type": "text",
58 "text": "Which object must be removed first to grasp the red mug?",
59 },
60 ],
61 },
62]
63
64# Preparation for inference
65text = processor.apply_chat_template(
66 messages,
67 tokenize=False,
68 add_generation_prompt=True,
69)
70image_inputs, video_inputs = process_vision_info(messages)
71inputs = processor(
72 text=[text],
73 images=image_inputs,
74 videos=video_inputs,
75 padding=True,
76 return_tensors="pt",
77)
78inputs = inputs.to(model.device)
79
80# Inference
81with torch.inference_mode():
82 generated_ids = model.generate(**inputs, max_new_tokens=1500)
83 generated_ids_trimmed = [
84 out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
85 ]
86 output_text = processor.batch_decode(
87 generated_ids_trimmed,
88 skip_special_tokens=True,
89 clean_up_tokenization_spaces=False,
90 )
91
92print(output_text[0])1python unograsp/inference/infer_nlp.py \
2 --model_path checkpoints/UnoGrasp-Ratio-RL-IoU-nlp-small \
3 --dataset_json ../UnoBench/UnoBenchSyn/test_nlp_small.jsonl \
4 --dataset_root ../UnoBench/UnoBenchSyn \
5 --out_dir outputs/inference/nlp_synthetic \
6 --max_new_tokens 15001python unograsp/evaluation/evaluate_nlp.py \
2 --pred_path outputs/inference/nlp_synthetic/predictions.jsonl \
3 --gt_path ../UnoBench/UnoBenchSyn/test_GT_small.json \
4 --npz_root ../UnoBench/UnoBenchSyn/annotations \
5 --dataset_type syntheticoutputs/inference/nlp_synthetic/predictions.jsonl1test_nlp_small.jsonl
2test_GT_small.json
3annotations/1@article{jiao2025obstruction,
2 title = {Obstruction reasoning for robotic grasping},
3 author = {Runyu Jiao and Matteo Bortolon and Francesco Giuliari and Alice Fasoli and Sergio Povoli and Guofeng Mei and Yiming Wang and Fabio Poiesi},
4 booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
5 year = {2026}
6}