update
Browse files- .gitattributes +0 -3
- action_head.safetensors +0 -3
- chat_template.jinja +0 -7
- config.json +0 -109
- flock_robotics_adapter.py +0 -84
- generation_config.json +0 -12
- model.safetensors +0 -3
- model_config.json +0 -6
- processor_config.json +0 -63
- tokenizer.json +0 -3
- tokenizer_config.json +0 -30
.gitattributes
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
action_head.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 2 |
-
model.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 3 |
-
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
action_head.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:2ea073913c7192233212994e8a31860643dfd3a61b86e4bc98a5d5d0cdee40e4
|
| 3 |
-
size 1208549892
|
|
|
|
|
|
|
|
|
|
|
|
chat_template.jinja
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system
|
| 2 |
-
You are a helpful assistant.<|im_end|>
|
| 3 |
-
{% endif %}<|im_start|>{{ message['role'] }}
|
| 4 |
-
{% if message['content'] is string %}{{ message['content'] }}<|im_end|>
|
| 5 |
-
{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>
|
| 6 |
-
{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant
|
| 7 |
-
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
DELETED
|
@@ -1,109 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"architectures": [
|
| 3 |
-
"Qwen2_5_VLForConditionalGeneration"
|
| 4 |
-
],
|
| 5 |
-
"dtype": "bfloat16",
|
| 6 |
-
"image_token_id": 151655,
|
| 7 |
-
"model_type": "qwen2_5_vl",
|
| 8 |
-
"text_config": {
|
| 9 |
-
"attention_dropout": 0.0,
|
| 10 |
-
"bos_token_id": 151643,
|
| 11 |
-
"dtype": "bfloat16",
|
| 12 |
-
"eos_token_id": 151645,
|
| 13 |
-
"hidden_act": "silu",
|
| 14 |
-
"hidden_size": 2048,
|
| 15 |
-
"initializer_range": 0.02,
|
| 16 |
-
"intermediate_size": 11008,
|
| 17 |
-
"layer_types": [
|
| 18 |
-
"full_attention",
|
| 19 |
-
"full_attention",
|
| 20 |
-
"full_attention",
|
| 21 |
-
"full_attention",
|
| 22 |
-
"full_attention",
|
| 23 |
-
"full_attention",
|
| 24 |
-
"full_attention",
|
| 25 |
-
"full_attention",
|
| 26 |
-
"full_attention",
|
| 27 |
-
"full_attention",
|
| 28 |
-
"full_attention",
|
| 29 |
-
"full_attention",
|
| 30 |
-
"full_attention",
|
| 31 |
-
"full_attention",
|
| 32 |
-
"full_attention",
|
| 33 |
-
"full_attention",
|
| 34 |
-
"full_attention",
|
| 35 |
-
"full_attention",
|
| 36 |
-
"full_attention",
|
| 37 |
-
"full_attention",
|
| 38 |
-
"full_attention",
|
| 39 |
-
"full_attention",
|
| 40 |
-
"full_attention",
|
| 41 |
-
"full_attention",
|
| 42 |
-
"full_attention",
|
| 43 |
-
"full_attention",
|
| 44 |
-
"full_attention",
|
| 45 |
-
"full_attention",
|
| 46 |
-
"full_attention",
|
| 47 |
-
"full_attention",
|
| 48 |
-
"full_attention",
|
| 49 |
-
"full_attention",
|
| 50 |
-
"full_attention",
|
| 51 |
-
"full_attention",
|
| 52 |
-
"full_attention",
|
| 53 |
-
"full_attention"
|
| 54 |
-
],
|
| 55 |
-
"max_position_embeddings": 128000,
|
| 56 |
-
"max_window_layers": 70,
|
| 57 |
-
"model_type": "qwen2_5_vl_text",
|
| 58 |
-
"num_attention_heads": 16,
|
| 59 |
-
"num_hidden_layers": 36,
|
| 60 |
-
"num_key_value_heads": 2,
|
| 61 |
-
"pad_token_id": null,
|
| 62 |
-
"rms_norm_eps": 1e-06,
|
| 63 |
-
"rope_parameters": {
|
| 64 |
-
"mrope_section": [
|
| 65 |
-
16,
|
| 66 |
-
24,
|
| 67 |
-
24
|
| 68 |
-
],
|
| 69 |
-
"rope_theta": 1000000.0,
|
| 70 |
-
"rope_type": "default",
|
| 71 |
-
"type": "mrope"
|
| 72 |
-
},
|
| 73 |
-
"sliding_window": null,
|
| 74 |
-
"use_cache": true,
|
| 75 |
-
"use_sliding_window": false,
|
| 76 |
-
"vocab_size": 151936
|
| 77 |
-
},
|
| 78 |
-
"tie_word_embeddings": true,
|
| 79 |
-
"transformers_version": "5.3.0",
|
| 80 |
-
"video_token_id": 151656,
|
| 81 |
-
"vision_config": {
|
| 82 |
-
"depth": 32,
|
| 83 |
-
"dtype": "bfloat16",
|
| 84 |
-
"fullatt_block_indexes": [
|
| 85 |
-
7,
|
| 86 |
-
15,
|
| 87 |
-
23,
|
| 88 |
-
31
|
| 89 |
-
],
|
| 90 |
-
"hidden_act": "silu",
|
| 91 |
-
"hidden_size": 1280,
|
| 92 |
-
"in_channels": 3,
|
| 93 |
-
"in_chans": 3,
|
| 94 |
-
"initializer_range": 0.02,
|
| 95 |
-
"intermediate_size": 3420,
|
| 96 |
-
"model_type": "qwen2_5_vl",
|
| 97 |
-
"num_heads": 16,
|
| 98 |
-
"out_hidden_size": 2048,
|
| 99 |
-
"patch_size": 14,
|
| 100 |
-
"spatial_merge_size": 2,
|
| 101 |
-
"spatial_patch_size": 14,
|
| 102 |
-
"temporal_patch_size": 2,
|
| 103 |
-
"tokens_per_second": 2,
|
| 104 |
-
"window_size": 112
|
| 105 |
-
},
|
| 106 |
-
"vision_end_token_id": 151653,
|
| 107 |
-
"vision_start_token_id": 151652,
|
| 108 |
-
"vision_token_id": 151654
|
| 109 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flock_robotics_adapter.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
| 1 |
-
from __future__ import annotations
|
| 2 |
-
|
| 3 |
-
import json
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
|
| 6 |
-
import numpy as np
|
| 7 |
-
import torch
|
| 8 |
-
import torch.nn as nn
|
| 9 |
-
from PIL import Image
|
| 10 |
-
from safetensors.torch import load_file
|
| 11 |
-
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
|
| 12 |
-
|
| 13 |
-
ACTION_DIM = 7
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
def build_action_head(hidden_size, head_hidden):
|
| 17 |
-
return nn.Sequential(
|
| 18 |
-
nn.Linear(hidden_size, head_hidden),
|
| 19 |
-
nn.GELU(),
|
| 20 |
-
nn.Linear(head_hidden, head_hidden),
|
| 21 |
-
nn.GELU(),
|
| 22 |
-
nn.Linear(head_hidden, ACTION_DIM),
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
class QwenVLAPolicy:
|
| 27 |
-
def __init__(self, model, processor, head, device):
|
| 28 |
-
self.model = model
|
| 29 |
-
self.processor = processor
|
| 30 |
-
self.head = head
|
| 31 |
-
self.device = device
|
| 32 |
-
self.model.eval()
|
| 33 |
-
self.head.eval()
|
| 34 |
-
|
| 35 |
-
@torch.no_grad()
|
| 36 |
-
def act(self, obs):
|
| 37 |
-
image = np.asarray(obs["image"], dtype=np.uint8)
|
| 38 |
-
instruction = str(obs.get("instruction", ""))
|
| 39 |
-
pil = Image.fromarray(image)
|
| 40 |
-
messages = [
|
| 41 |
-
{
|
| 42 |
-
"role": "user",
|
| 43 |
-
"content": [
|
| 44 |
-
{"type": "image"},
|
| 45 |
-
{"type": "text", "text": instruction},
|
| 46 |
-
],
|
| 47 |
-
}
|
| 48 |
-
]
|
| 49 |
-
text = self.processor.apply_chat_template(
|
| 50 |
-
messages, tokenize=False, add_generation_prompt=True
|
| 51 |
-
)
|
| 52 |
-
inputs = self.processor(
|
| 53 |
-
text=[text], images=[pil], return_tensors="pt", padding=True
|
| 54 |
-
)
|
| 55 |
-
inputs = {k: v.to(self.device) for k, v in inputs.items()}
|
| 56 |
-
out = self.model(**inputs, output_hidden_states=True, use_cache=False)
|
| 57 |
-
hidden = out.hidden_states[-1]
|
| 58 |
-
mask = inputs["attention_mask"].unsqueeze(-1).to(hidden.dtype)
|
| 59 |
-
pooled = (hidden * mask).sum(1) / mask.sum(1).clamp(min=1)
|
| 60 |
-
action = torch.tanh(self.head(pooled.float())).squeeze(0).cpu().numpy()
|
| 61 |
-
return np.clip(action, -1.0, 1.0).astype(np.float32)
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
def load_policy(model_dir, device, dtype):
|
| 65 |
-
model_root = Path(model_dir)
|
| 66 |
-
cfg = json.loads((model_root / "model_config.json").read_text())
|
| 67 |
-
use_cuda = device == "cuda" and torch.cuda.is_available()
|
| 68 |
-
torch_device = torch.device("cuda" if use_cuda else "cpu")
|
| 69 |
-
torch_dtype = (
|
| 70 |
-
torch.bfloat16
|
| 71 |
-
if (use_cuda and str(dtype) == "bfloat16")
|
| 72 |
-
else torch.float32
|
| 73 |
-
)
|
| 74 |
-
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 75 |
-
model_root, dtype=torch_dtype
|
| 76 |
-
).to(torch_device)
|
| 77 |
-
processor = AutoProcessor.from_pretrained(model_root)
|
| 78 |
-
head = build_action_head(int(cfg["hidden_size"]), int(cfg["head_hidden"])).to(
|
| 79 |
-
torch_device
|
| 80 |
-
)
|
| 81 |
-
head.load_state_dict(
|
| 82 |
-
load_file(str(model_root / "action_head.safetensors"), device=str(torch_device))
|
| 83 |
-
)
|
| 84 |
-
return QwenVLAPolicy(model, processor, head, torch_device)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generation_config.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"bos_token_id": 151643,
|
| 3 |
-
"do_sample": true,
|
| 4 |
-
"eos_token_id": [
|
| 5 |
-
151645,
|
| 6 |
-
151643
|
| 7 |
-
],
|
| 8 |
-
"pad_token_id": 151643,
|
| 9 |
-
"repetition_penalty": 1.05,
|
| 10 |
-
"temperature": 1e-06,
|
| 11 |
-
"transformers_version": "5.3.0"
|
| 12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:05a02cbf57990c4d9b176489083c8509eec59daea405ce86043f199e1b18aea2
|
| 3 |
-
size 7509338080
|
|
|
|
|
|
|
|
|
|
|
|
model_config.json
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"base_model": "Qwen/Qwen2.5-VL-3B-Instruct",
|
| 3 |
-
"hidden_size": 2048,
|
| 4 |
-
"head_hidden": 16384,
|
| 5 |
-
"action_dim": 7
|
| 6 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processor_config.json
DELETED
|
@@ -1,63 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"image_processor": {
|
| 3 |
-
"data_format": "channels_first",
|
| 4 |
-
"do_convert_rgb": true,
|
| 5 |
-
"do_normalize": true,
|
| 6 |
-
"do_rescale": true,
|
| 7 |
-
"do_resize": true,
|
| 8 |
-
"image_mean": [
|
| 9 |
-
0.48145466,
|
| 10 |
-
0.4578275,
|
| 11 |
-
0.40821073
|
| 12 |
-
],
|
| 13 |
-
"image_processor_type": "Qwen2VLImageProcessorFast",
|
| 14 |
-
"image_std": [
|
| 15 |
-
0.26862954,
|
| 16 |
-
0.26130258,
|
| 17 |
-
0.27577711
|
| 18 |
-
],
|
| 19 |
-
"merge_size": 2,
|
| 20 |
-
"patch_size": 14,
|
| 21 |
-
"resample": 3,
|
| 22 |
-
"rescale_factor": 0.00392156862745098,
|
| 23 |
-
"size": {
|
| 24 |
-
"longest_edge": 12845056,
|
| 25 |
-
"shortest_edge": 3136
|
| 26 |
-
},
|
| 27 |
-
"temporal_patch_size": 2
|
| 28 |
-
},
|
| 29 |
-
"processor_class": "Qwen2_5_VLProcessor",
|
| 30 |
-
"video_processor": {
|
| 31 |
-
"data_format": "channels_first",
|
| 32 |
-
"default_to_square": true,
|
| 33 |
-
"do_convert_rgb": true,
|
| 34 |
-
"do_normalize": true,
|
| 35 |
-
"do_rescale": true,
|
| 36 |
-
"do_resize": true,
|
| 37 |
-
"do_sample_frames": false,
|
| 38 |
-
"image_mean": [
|
| 39 |
-
0.48145466,
|
| 40 |
-
0.4578275,
|
| 41 |
-
0.40821073
|
| 42 |
-
],
|
| 43 |
-
"image_processor_type": "Qwen2VLImageProcessor",
|
| 44 |
-
"image_std": [
|
| 45 |
-
0.26862954,
|
| 46 |
-
0.26130258,
|
| 47 |
-
0.27577711
|
| 48 |
-
],
|
| 49 |
-
"max_frames": 768,
|
| 50 |
-
"merge_size": 2,
|
| 51 |
-
"min_frames": 4,
|
| 52 |
-
"patch_size": 14,
|
| 53 |
-
"resample": 3,
|
| 54 |
-
"rescale_factor": 0.00392156862745098,
|
| 55 |
-
"return_metadata": false,
|
| 56 |
-
"size": {
|
| 57 |
-
"longest_edge": 12845056,
|
| 58 |
-
"shortest_edge": 3136
|
| 59 |
-
},
|
| 60 |
-
"temporal_patch_size": 2,
|
| 61 |
-
"video_processor_type": "Qwen2VLVideoProcessor"
|
| 62 |
-
}
|
| 63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tokenizer.json
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8
|
| 3 |
-
size 11421892
|
|
|
|
|
|
|
|
|
|
|
|
tokenizer_config.json
DELETED
|
@@ -1,30 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"add_prefix_space": false,
|
| 3 |
-
"backend": "tokenizers",
|
| 4 |
-
"bos_token": null,
|
| 5 |
-
"clean_up_tokenization_spaces": false,
|
| 6 |
-
"eos_token": "<|im_end|>",
|
| 7 |
-
"errors": "replace",
|
| 8 |
-
"extra_special_tokens": [
|
| 9 |
-
"<|im_start|>",
|
| 10 |
-
"<|im_end|>",
|
| 11 |
-
"<|object_ref_start|>",
|
| 12 |
-
"<|object_ref_end|>",
|
| 13 |
-
"<|box_start|>",
|
| 14 |
-
"<|box_end|>",
|
| 15 |
-
"<|quad_start|>",
|
| 16 |
-
"<|quad_end|>",
|
| 17 |
-
"<|vision_start|>",
|
| 18 |
-
"<|vision_end|>",
|
| 19 |
-
"<|vision_pad|>",
|
| 20 |
-
"<|image_pad|>",
|
| 21 |
-
"<|video_pad|>"
|
| 22 |
-
],
|
| 23 |
-
"is_local": false,
|
| 24 |
-
"model_max_length": 131072,
|
| 25 |
-
"pad_token": "<|endoftext|>",
|
| 26 |
-
"processor_class": "Qwen2_5_VLProcessor",
|
| 27 |
-
"split_special_tokens": false,
|
| 28 |
-
"tokenizer_class": "Qwen2Tokenizer",
|
| 29 |
-
"unk_token": null
|
| 30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|