Downloads · 30 days
17
5% of all-time downloads
xjtupanda/MiniCPM-V-30K-mix-finetune
MiniCPM-V-30K-mix-finetune is a video-text-to-text model from xjtupanda. Use it for the video-text-to-text task on the model card, and read the license before you ship it in a product. It is set up for transformers. The card lists the license as apache-2.0.
Downloads · 30 days
17
5% of all-time downloads
All-time downloads
316
Public
Parameters
8.5B
17.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors17.1 GB · 100%
From the Hugging Face model README
This model, named Sparrow, was presented in the paper "Sparrow: Data-Efficient Video-LLM with Text-to-Image Augmentation". It builds upon the success of Multimodal Large Language Models (MLLMs) in vision understanding, specifically addressing the challenge of data efficiency in video-LLMs.
The paper revisits scaling with synthetic data and focuses on developing video-LLMs from a data-centric perspective. Preliminary experiments revealed a low learning efficiency when simply scaling up video data samples, which was attributed to a lack of instruction diversity.
Key Highlights:
The video-LLM is fine-tuned from the image-LLM MiniCPM-Llama3-V-2_5.
You can use the Sparrow model with the transformers library. For more detailed instructions on video loading (e.g., extracting frames) and advanced usage scenarios, please refer to the project's GitHub repository.
First, ensure you have the necessary dependencies installed:
pip install transformers torch accelerate
pip install -U flash-attn --no-build-isolation # For efficient training and inference
Here's a quick example to get started with inference using an image as a proxy for video frames. In a full video-LLM setup, you would process a sequence of frames from a video.
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoProcessor
import torch
from PIL import Image
import requests
from io import BytesIO
# The model is fine-tuned from openbmb/MiniCPM-Llama3-V-2_5
model_id = "openbmb/MiniCPM-Llama3-V-2_5"
# Load model, tokenizer, and processor
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, device_map="cuda", trust_remote_code=True)
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
model.eval()
# --- Example: Using a single image as a proxy for a video frame ---
# For a real video-text-to-text task, you would typically:
# 1. Load a video using libraries like `decord` or `imageio`.
# 2. Extract a sequence of representative frames from the video.
# 3. Pass these frames as a list of PIL Images to the processor.
# For demonstration, we use a single dummy image:
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/tasks/car.jpg"
response = requests.get(image_url)
image_frame = Image.open(BytesIO(response.content)).convert("RGB")
# Prepare the conversation input with image and text
# For video input, 'content' would be a list like: [frame1, frame2, ..., question_text]
question = "Describe the scene shown in this image in detail."
messages = [{'role': 'user', 'content': [image_frame, question]}]
# Process inputs
inputs = processor(messages, return_tensors="pt")
inputs = {k: v.to(model.device) for k, v in inputs.items()}
# Generate text response
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=100,
do_sample=False,
repetition_penalty=1.05,
)
response_text = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(response_text)