|
Download README.md from yogkul2000/VideoPASTA: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/yogkul2000/VideoPASTA/resolve/main/README.md
- Command line
-
hf download hf://yogkul2000/VideoPASTA/README.md
-
curl -L -o README.md https://huggingface.co/yogkul2000/VideoPASTA/resolve/main/README.md
1.29 kB
| ```python | |
| from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor | |
| from qwen_vl_utils import process_vision_info | |
| model = Qwen2_5_VLForConditionalGeneration.from_pretrained( | |
| "/path/to/model", | |
| torch_dtype="auto", | |
| device_map="auto" | |
| ) | |
| processor = AutoProcessor.from_pretrained("/path/to/model") | |
| messages = [ | |
| { | |
| "role": "user", | |
| "content": [ | |
| { | |
| "type": "video", | |
| "video": "/path/to/video.mp4", | |
| }, | |
| {"type": "text", "text": "Describe this video in detail."}, | |
| ], | |
| } | |
| ] | |
| text = processor.apply_chat_template( | |
| messages, tokenize=False, add_generation_prompt=True | |
| ) | |
| image_inputs, video_inputs, video_kwargs = process_vision_info(messages, return_video_kwargs=True) | |
| inputs = processor( | |
| text=[text], | |
| images=image_inputs, | |
| videos=video_inputs, | |
| padding=True, | |
| return_tensors="pt", | |
| **video_kwargs, | |
| ) | |
| inputs = inputs.to("cuda") | |
| generated_ids = model.generate(**inputs, max_new_tokens=512) | |
| generated_ids_trimmed = [ | |
| out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids) | |
| ] | |
| output_text = processor.batch_decode( | |
| generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False | |
| ) | |
| print(output_text[0]) |