Visual Question Answering
Transformers
Safetensors
English
videollama2_mistral
text-generation
multimodal large language model
large video-language model
Instructions to use Aliayub1995/VideoLLaMA2-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Aliayub1995/VideoLLaMA2-7B with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "visual-question-answering" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("visual-question-answering", model="Aliayub1995/VideoLLaMA2-7B")# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Aliayub1995/VideoLLaMA2-7B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update videollama2/__init__.py
Browse files- videollama2/__init__.py +4 -2
videollama2/__init__.py
CHANGED
|
@@ -3,6 +3,7 @@ import copy
|
|
| 3 |
import warnings
|
| 4 |
import shutil
|
| 5 |
from functools import partial
|
|
|
|
| 6 |
|
| 7 |
import torch
|
| 8 |
import logging
|
|
@@ -32,7 +33,7 @@ def model_init(model_path=None, **kwargs):
|
|
| 32 |
return model, processor, tokenizer
|
| 33 |
|
| 34 |
|
| 35 |
-
def mm_infer(
|
| 36 |
"""inference api of VideoLLaMA2 for video understanding.
|
| 37 |
|
| 38 |
Args:
|
|
@@ -45,7 +46,8 @@ def mm_infer(image_or_video, instruct, model, tokenizer, modal='video', **kwargs
|
|
| 45 |
Returns:
|
| 46 |
str: response of the model.
|
| 47 |
"""
|
| 48 |
-
|
|
|
|
| 49 |
# 1. text preprocess (tag process & generate prompt).
|
| 50 |
if modal == 'image':
|
| 51 |
modal_token = DEFAULT_IMAGE_TOKEN
|
|
|
|
| 3 |
import warnings
|
| 4 |
import shutil
|
| 5 |
from functools import partial
|
| 6 |
+
import gdown
|
| 7 |
|
| 8 |
import torch
|
| 9 |
import logging
|
|
|
|
| 33 |
return model, processor, tokenizer
|
| 34 |
|
| 35 |
|
| 36 |
+
def mm_infer(url, instruct, model, tokenizer, modal='video', **kwargs):
|
| 37 |
"""inference api of VideoLLaMA2 for video understanding.
|
| 38 |
|
| 39 |
Args:
|
|
|
|
| 46 |
Returns:
|
| 47 |
str: response of the model.
|
| 48 |
"""
|
| 49 |
+
image_or_video = 'Temp.mp4'
|
| 50 |
+
gdown.download(url, output, quiet=False)
|
| 51 |
# 1. text preprocess (tag process & generate prompt).
|
| 52 |
if modal == 'image':
|
| 53 |
modal_token = DEFAULT_IMAGE_TOKEN
|