Update README.md
Browse filesadd arxiv and github io
README.md
CHANGED
|
@@ -1,214 +1,216 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
---
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
# iFlyBot-VLM
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-

|
| 8 |
+
[iFlyBot-VLA.github.io](https://xuwenjie401.github.io/iFlyBot-VLA.github.io/)
|
| 9 |
+
|
| 10 |
+
## 🔥Introduction
|
| 11 |
+
|
| 12 |
+
We introduce iFlyBot-VLM, a general-purpose Vision-Language-Model (VLM) specifically engineered for the domain of Embodied Intelligence. The primary objective of this model is to bridge the cross-modal semantic gap between high-dimensional environmental perception and low-level robot motion control. It achieves this by abstracting complex scene information into an "Operational Language" that is body-agnostic and transferable, thus enabling seamless perception-to-action closed-loop coordination.
|
| 13 |
+
|
| 14 |
+
The architecture of iFlyBot-VLM is designed to realize four critical functional capabilities in the embodied domain:
|
| 15 |
+
**🧭Spatial Understanding and Metric**: Provides the model with the capacity to understand spatial relationships and perform relative position estimation among objects in the environment.
|
| 16 |
+
**🎯Interactive Target Grounding**: Supports diverse grounding mechanisms, including 2D/3D object detection in the visual modality, language-based object and spatial referring, and the prediction of critical object affordance regions.
|
| 17 |
+
**🤖Action Abstraction and Control Parameter Generation**: Generates outputs directly relevant to the manipulation domain, providing grasp poses and manipulation trajectories.
|
| 18 |
+
**📋Task Planning**: Leveraging the current scene Understanding, this module performs multi-step prediction to decompose complex tasks into a sequence of atomic skills, fundamentally supporting the robust execution of long-horizon tasks.
|
| 19 |
+
|
| 20 |
+
We anticipate that iFlyBot-VLM will serve as an efficient and scalable foundation model, driving the advancement of embodied AI from single-task capabilities toward generalist intelligent agents.
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
<div style="display: flex; gap: 1em; max-width: 100%;">
|
| 24 |
+
<img
|
| 25 |
+
src="https://huggingface.co/datasets/iFlyBot/iFlyBotVLM-Repo/resolve/main/images/smart_donut_chart.png"
|
| 26 |
+
style="flex: 1; max-width: 60%; height: auto; object-fit: contain;"
|
| 27 |
+
alt="iFlyBotVLM Traning Data"
|
| 28 |
+
>
|
| 29 |
+
<img
|
| 30 |
+
src="https://huggingface.co/datasets/iFlyBot/iFlyBotVLM-Repo/resolve/main/images/radar_performance.png"
|
| 31 |
+
style="flex: 1; max-width: 40%; height: auto; object-fit: contain;"
|
| 32 |
+
alt="iFlyBotVLM Performance"
|
| 33 |
+
>
|
| 34 |
+
</div>
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
## 🏗️Model Architecture
|
| 38 |
+
|
| 39 |
+
iFlyBot-VLM inherits the robust, three-stage "ViT-Projector-LLM" paradigm from established Vision-Language Models. It integrates a dedicated, incrementally pre-trained Visual Encoder with an advanced Language Model via a simple, randomly initialized MLP projector for efficient feature alignment.
|
| 40 |
+
|
| 41 |
+
The core enhancement lies in the ViT's Positional Encoding (PE) layer. Instead of relying solely on the original 448 dimension PE, we employ Bicubic Interpolation to intelligently upsample the learned positional embeddings from 448 to an enriched dimension of 896. This novel approach, termed Dimension-Expanded Position Embedding (DEPE), provides a significantly more nuanced spatial context vector for each visual token. This dimensional enrichment allows the model to capture more complex positional and relative spatial information without increasing the sequence length, thereby enhancing the model's ability to perform fine-grained visual reasoning and detailed localization tasks.
|
| 42 |
+
|
| 43 |
+

|
| 44 |
+
|
| 45 |
+
## 📊Model Performance
|
| 46 |
+
|
| 47 |
+
iFlyBot-VLM demonstrates superior performance across various challenging benchmarks.
|
| 48 |
+
|
| 49 |
+

|
| 50 |
+
|
| 51 |
+

|
| 52 |
+
|
| 53 |
+
iFlyBot-VLM-8B achieves state-of-the-art (SOTA) or near-SOTA performance on ten spatial Understanding, spatial perception, and temporal task planning benchmarks: Where2Place, Refspatial-bench, ShareRobot-affordance, ShareRobot-trajectory, BLINK(spatial), EmbSpatial, ERQA, CVBench, SAT, EgoPlan2.
|
| 54 |
+
|
| 55 |
+
## 🚀Quick Start
|
| 56 |
+
|
| 57 |
+
### Using 🤗 Transformers to Chat
|
| 58 |
+
|
| 59 |
+
We provide an example code to run `iFlyBot-VLM-8B` using `transformers`.
|
| 60 |
+
|
| 61 |
+
> Please use transformers>=4.37.2 to ensure the model works normally.
|
| 62 |
+
|
| 63 |
+
<details>
|
| 64 |
+
<summary>Python code</summary>
|
| 65 |
+
|
| 66 |
+
```python
|
| 67 |
+
import math
|
| 68 |
+
import numpy as np
|
| 69 |
+
import torch
|
| 70 |
+
import torchvision.transforms as T
|
| 71 |
+
from PIL import Image
|
| 72 |
+
from torchvision.transforms.functional import InterpolationMode
|
| 73 |
+
from transformers import AutoModel, AutoTokenizer,AutoConfig
|
| 74 |
+
from tqdm import tqdm
|
| 75 |
+
import json
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
IMAGENET_MEAN = (0.485, 0.456, 0.406)
|
| 79 |
+
IMAGENET_STD = (0.229, 0.224, 0.225)
|
| 80 |
+
|
| 81 |
+
class IflyRoboInference:
|
| 82 |
+
def __init__(self, model_path=''):
|
| 83 |
+
self.model = AutoModel.from_pretrained(
|
| 84 |
+
model_path,
|
| 85 |
+
torch_dtype=torch.bfloat16,
|
| 86 |
+
load_in_8bit=False,
|
| 87 |
+
low_cpu_mem_usage=True,
|
| 88 |
+
use_flash_attn=True,
|
| 89 |
+
trust_remote_code=True,
|
| 90 |
+
device_map="balanced").eval() # "auto", "balanced"
|
| 91 |
+
self.tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True, use_fast=False)
|
| 92 |
+
self.generation_config = dict(
|
| 93 |
+
do_sample=True,
|
| 94 |
+
temperature=0.5,
|
| 95 |
+
top_p = 0.0,
|
| 96 |
+
top_k = 1,
|
| 97 |
+
max_new_tokens=16384
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
def build_transform(self, input_size):
|
| 101 |
+
MEAN, STD = IMAGENET_MEAN, IMAGENET_STD
|
| 102 |
+
transform = T.Compose([
|
| 103 |
+
T.Lambda(lambda img: img.convert('RGB') if img.mode != 'RGB' else img),
|
| 104 |
+
T.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC),
|
| 105 |
+
T.ToTensor(),
|
| 106 |
+
T.Normalize(mean=MEAN, std=STD)
|
| 107 |
+
])
|
| 108 |
+
return transform
|
| 109 |
+
|
| 110 |
+
def find_closest_aspect_ratio(self, aspect_ratio, target_ratios, width, height, image_size):
|
| 111 |
+
best_ratio_diff = float('inf')
|
| 112 |
+
best_ratio = (1, 1)
|
| 113 |
+
area = width * height
|
| 114 |
+
for ratio in target_ratios:
|
| 115 |
+
target_aspect_ratio = ratio[0] / ratio[1]
|
| 116 |
+
ratio_diff = abs(aspect_ratio - target_aspect_ratio)
|
| 117 |
+
if ratio_diff < best_ratio_diff:
|
| 118 |
+
best_ratio_diff = ratio_diff
|
| 119 |
+
best_ratio = ratio
|
| 120 |
+
elif ratio_diff == best_ratio_diff:
|
| 121 |
+
if area > 0.5 * image_size * image_size * ratio[0] * ratio[1]:
|
| 122 |
+
best_ratio = ratio
|
| 123 |
+
return best_ratio
|
| 124 |
+
|
| 125 |
+
def dynamic_preprocess(self, image, min_num=1, max_num=12, image_size=896, use_thumbnail=False):
|
| 126 |
+
orig_width, orig_height = image.size
|
| 127 |
+
aspect_ratio = orig_width / orig_height
|
| 128 |
+
|
| 129 |
+
target_ratios = set(
|
| 130 |
+
(i, j) for n in range(min_num, max_num + 1) for i in range(1, n + 1) for j in range(1, n + 1) if
|
| 131 |
+
i * j <= max_num and i * j >= min_num)
|
| 132 |
+
target_ratios = sorted(target_ratios, key=lambda x: x[0] * x[1])
|
| 133 |
+
|
| 134 |
+
target_aspect_ratio = self.find_closest_aspect_ratio(
|
| 135 |
+
aspect_ratio, target_ratios, orig_width, orig_height, image_size)
|
| 136 |
+
|
| 137 |
+
target_width = image_size * target_aspect_ratio[0]
|
| 138 |
+
target_height = image_size * target_aspect_ratio[1]
|
| 139 |
+
blocks = target_aspect_ratio[0] * target_aspect_ratio[1]
|
| 140 |
+
|
| 141 |
+
resized_img = image.resize((target_width, target_height))
|
| 142 |
+
processed_images = []
|
| 143 |
+
for i in range(blocks):
|
| 144 |
+
box = (
|
| 145 |
+
(i % (target_width // image_size)) * image_size,
|
| 146 |
+
(i // (target_width // image_size)) * image_size,
|
| 147 |
+
((i % (target_width // image_size)) + 1) * image_size,
|
| 148 |
+
((i // (target_width // image_size)) + 1) * image_size
|
| 149 |
+
)
|
| 150 |
+
split_img = resized_img.crop(box)
|
| 151 |
+
processed_images.append(split_img)
|
| 152 |
+
assert len(processed_images) == blocks
|
| 153 |
+
if use_thumbnail and len(processed_images) != 1:
|
| 154 |
+
thumbnail_img = image.resize((image_size, image_size))
|
| 155 |
+
processed_images.append(thumbnail_img)
|
| 156 |
+
return processed_images
|
| 157 |
+
|
| 158 |
+
def load_image(self, image_file, input_size=896, max_num=12):
|
| 159 |
+
image = Image.open(image_file).convert('RGB')
|
| 160 |
+
transform = self.build_transform(input_size=input_size)
|
| 161 |
+
images = self.dynamic_preprocess(image, image_size=input_size, use_thumbnail=True, max_num=max_num)
|
| 162 |
+
pixel_values = [transform(image) for image in images]
|
| 163 |
+
pixel_values = torch.stack(pixel_values)
|
| 164 |
+
return pixel_values
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
def forward_multi_image(self, image_paths: list, question: dict):
|
| 168 |
+
pixel_values = []
|
| 169 |
+
num_patches_list = []
|
| 170 |
+
resize_size = 448
|
| 171 |
+
for i, image_path in enumerate(image_paths):
|
| 172 |
+
pixel_value = self.load_image(image_path, input_size=resize_size).to(torch.bfloat16).cuda()
|
| 173 |
+
pixel_values.append(pixel_value)
|
| 174 |
+
num_patches_list.append(pixel_value.size(0))
|
| 175 |
+
pixel_values = torch.cat(tuple(pixel_values), dim=0)
|
| 176 |
+
print(question)
|
| 177 |
+
response, history = self.model.chat(self.tokenizer, pixel_values, question["prompt"], self.generation_config, history=None, return_history=True)
|
| 178 |
+
print(response)
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def test_spatial_from_blink():
|
| 182 |
+
hf_path = "iFlyBot/iFlyBotVLM"
|
| 183 |
+
ifly_robo_infer = IflyRoboInference(hf_path)
|
| 184 |
+
question = {
|
| 185 |
+
"idx": "val_Spatial_Relation_143",
|
| 186 |
+
"sub_task" : "Spatial Relation",
|
| 187 |
+
"prompt": "<image> Is the person behind the cup?\nSelect from the following choices.\n(A) yes\n(B) no.\nPlease answer directly with only the letter of the correct option and nothing else."
|
| 188 |
+
}
|
| 189 |
+
image_path = [
|
| 190 |
+
"./examples-images/val_Spatial_Relation_143_1.jpg"
|
| 191 |
+
]
|
| 192 |
+
ifly_robo_infer.forward_multi_image(image_path, question)
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def test_visual_correspondence_from_blink():
|
| 196 |
+
hf_path = "iFlyBot/iFlyBotVLM"
|
| 197 |
+
ifly_robo_infer = IflyRoboInference(hf_path)
|
| 198 |
+
question = {
|
| 199 |
+
"idx": "val_Visual_Correspondence_1",
|
| 200 |
+
"sub_task" : "Visual Correspondence",
|
| 201 |
+
"prompt": "<image> <image> A point is circled on the first image, labeled with REF. We change the camera position or lighting and shoot the second image. You are given multiple red-circled points on the second image, choices of \"A, B, C, D\" are drawn beside each circle. Which point on the second image corresponds to the point in the first image? Select from the following options.\n(A) Point A\n(B) Point B\n(C) Point C\n(D) Point D.\nPlease answer directly with only the letter of the correct option and nothing else."
|
| 202 |
+
}
|
| 203 |
+
image_path = [
|
| 204 |
+
"./examples-images/val_Visual_Correspondence_1_1.jpg",
|
| 205 |
+
"./examples-images/val_Visual_Correspondence_1_2.jpg"
|
| 206 |
+
]
|
| 207 |
+
ifly_robo_infer.forward_multi_image(image_path, question)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
if __name__ == '__main__':
|
| 211 |
+
test_spatial_from_blink()
|
| 212 |
+
test_visual_correspondence_from_blink()
|
| 213 |
+
test_task_plan_from_egoplan2()
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
</details>
|