Downloads · 30 days
0
TaherFattahi/MetaWorld-VLA-openai-clip-vit
MetaWorld-VLA-openai-clip-vit is a reinforcement learning model from TaherFattahi. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as mit.
A lightweight Vision-Language-Action (VLA) baseline for MetaWorld robot-arm tasks using a pretrained CLIP-ViT vision transformer(openai/clip-vit-base-patch32), a small text transformer, and robot-state fusion—trained…
Downloads · 30 days
0
Access
Public
Updated Dec 27, 2025
Repo size
408 MB
Likes
0
Public
Click a slice to open those files.
.pt406 MB · 100%
From the Hugging Face model README
A lightweight Vision-Language-Action (VLA) baseline for MetaWorld robot-arm tasks using a pretrained CLIP-ViT vision transformer(openai/clip-vit-base-patch32), a small text transformer, and robot-state fusion—trained with behavior cloning and evaluated in a MetaWorld MT1 wrapper.
test.py rollout scriptpip install -r requirements.txt
python3 collect_data.py \
--env-name soccer-v3 \
--camera-name corner \
--episodes 100 \
--max-steps 140 \
--output-path data/metaworld_soccer_bc.npz \
--resize-to 480
python3 train.py \
--data data/metaworld_soccer_bc.npz \
--out checkpoints/metaworld_soccer.pt \
--device cuda
python3 test.py \
--checkpoint checkpoints/metaworld_soccer.pt \
--env-name soccer-v3 \
--episodes 5 \
--max-steps 150 \
--instruction "Shoot the ball into the goal" \
--device cuda \
--save-video \
--video-dir videos
A lightweight Vision-Language-Action (VLA) policy for MetaWorld trained with Behavior Cloning (BC).
The model class is: models/vla_clip_bc.py::VLAClipBC
At a high level:
(RGB image, instruction token IDs, robot state) → fused embedding → action
Inputs
img: RGB image tensor (B, 3, H, W) in [0, 1]text_ids: token IDs (B, T) from SimpleTokenizer (padding id 0)state: robot state vector (B, S)Outputs
action: continuous action (B, A) (optionally tanh squashed to [-1, 1])Implemented in VLAClipBC.encode_vision():
Preprocess
224×224F.interpolate(img, size=(224,224))img = (img - clip_mean) / clip_stdCLIP Vision Transformer
self.vision = CLIPVisionModel.from_pretrained("openai/clip-vit-base-patch32")out.pooler_output (shape (B, 768) for ViT-B/32)Projection to d_model
self.vision_proj = Linear(768 → D)v with shape (B, D)D = 512)CLIPVisionModel (ViT-B/32) internals (high-level)
Note: when
freeze_vision=True, CLIP vision parameters are frozen.
SimpleTextTransformer)Implemented in SimpleTextTransformer.forward():
Embeddings
Embedding(vocab_size, D, padding_idx=0)Embedding(max_len=64, D)x = tok_emb(text_ids) + pos_emb(pos)Transformer Encoder
nn.TransformerEncoder(num_layers=text_layers)norm_first=True):
LayerNorm(D)Masked Mean Pooling
text_ids == 0t with shape (B, D)Default config:
text_layers = 2text_heads = 8max_len = 64Implemented in VLAClipBC.encode_state():
Normalize state
state_mean and state_std are stored in buffers (from training dataset stats)s = (state - state_mean) / state_stdMLP Encoder
LayerNorm(S)Linear(S → 2D)GELULinear(2D → D)Result: state embedding s with shape (B, D)
Implemented in VLAClipBC.forward():
Stack 3 tokens
tokens = stack([v, t, s], dim=1)(B, 3, D)Fusion TransformerEncoder
nn.TransformerEncoder(num_layers=fusion_layers)Take token 0
x = LayerNorm(fused[:, 0])(B, D)Default config:
fusion_layers = 2fusion_heads = 8Implemented in VLAClipBC.forward():
Linear(D → 2D)GELULinear(2D → A)tanh(action) (keeps actions in [-1, 1])Result: (B, A)
Assuming default D=512 and CLIP ViT-B/32 hidden size 768:
(B,3,H,W) → resize/normalize → CLIP ViT → (B,768) → vision_proj → v (B,512)(B,T) → embeddings → text transformer → masked mean pool → t (B,512)(B,S) → normalize → MLP → s (B,512)(B,3,512) → fusion transformer → take token0 → (B,512)(B,512) → (B,A) → optional tanhTraining uses Behavior Cloning (BC) from demonstrations:
(img, text_ids, state) → expert_actionMSE(pred_action, expert_action)AdamW(trainable_params, lr, weight_decay)clip_grad_norm_)from models.vla_clip_bc import VLAClipBC
model = VLAClipBC(vocab_size=2000, state_dim=39, action_dim=4, d_model=512, freeze_vision=True)
print(model) # prints full nested module tree
print(model.vision) # prints CLIP vision internals
Contributions are welcome. If you find a bug or have a feature request, please open an issue or submit a pull request.
This project is released under the <b>MIT License</b>. Feel free to use, modify, and distribute for your own projects.