Views
No views yet

transformers library. Ensure you have the necessary dependencies installed as outlined in the project's GitHub repository.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer, AutoProcessor
3from PIL import Image
4import requests
5from io import BytesIO
6
7# Load model and processor
8model_id = "mengwei0427/StreamVLN_Video_qwen_1_5_r2r_rxr_envdrop_scalevln"
9model = AutoModelForCausalLM.from_pretrained(
10 model_id,
11 torch_dtype=torch.bfloat16, # Adjust dtype based on your hardware (e.g., torch.float16 for Ampere GPUs)
12 device_map="auto",
13 trust_remote_code=True # Required for custom modeling components like Qwen-VL
14)
15processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
16tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
17
18# Example: This model is designed for Vision-and-Language Navigation (VLN).
19# The full inference loop involves continuous visual stream processing and action generation
20# within an environment. The snippet below shows a basic setup for text-image input.
21# For complete VLN usage, including environment setup and action generation,
22# please refer to the project's [GitHub repository](https://github.com/OpenRobotLab/StreamVLN).
23
24# Load a sample image (replace with actual environment image in VLN tasks)
25image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg?width=400"
26image = Image.open(BytesIO(requests.get(image_url).content)).convert("RGB")
27
28# Prepare text input using the chat template
29messages = [
30 {"role": "user", "content": "What is in the image? Describe it."},
31]
32text_input = tokenizer.apply_chat_template(
33 messages, tokenize=False, add_generation_prompt=True
34)
35
36# Process inputs (text and image)
37inputs = processor(text=text_input, images=image, return_tensors="pt").to(model.device)
38
39# Generate response
40output_ids = model.generate(
41 **inputs,
42 max_new_tokens=256, # Increase max_new_tokens for more detailed responses
43 do_sample=True,
44 temperature=0.7,
45 top_p=0.8,
46)
47
48# Decode and print the output, skipping the input prompt
49output_text = tokenizer.decode(output_ids[0][len(inputs.input_ids[0]):], skip_special_tokens=True)
50print(output_text)1@misc{wei2025streamvlnstreamingvisionandlanguagenavigation,
2 title={StreamVLN: Streaming Vision-and-Language Navigation via SlowFast Context Modeling},
3 author={Meng Wei and Chenyang Wan and Xiqian Yu and Tai Wang and Yuqiang Yang and Xiaohan Mao and Chenming Zhu and Wenzhe Cai and Hanqing Wang and Yilun Chen and Xihui Liu and Jiangmiao Pang},
4 year={2025},
5 eprint={2507.05240},
6 archivePrefix={arXiv},
7 primaryClass={cs.RO},
8 url={https://arxiv.org/abs/2507.05240},
9}