Instructions to use notbdq/videogpt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use notbdq/videogpt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="notbdq/videogpt")# Load model directly from transformers import AutoTokenizer, AutoModelForImageTextToText tokenizer = AutoTokenizer.from_pretrained("notbdq/videogpt") model = AutoModelForImageTextToText.from_pretrained("notbdq/videogpt") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use notbdq/videogpt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "notbdq/videogpt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "notbdq/videogpt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/notbdq/videogpt
- SGLang
How to use notbdq/videogpt with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "notbdq/videogpt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "notbdq/videogpt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "notbdq/videogpt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "notbdq/videogpt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use notbdq/videogpt with Docker Model Runner:
docker model run hf.co/notbdq/videogpt
VideoGPT - A Spatiotemporal Video Captioning Model
Vision Encoder Model: timesformer-base-finetuned-k600
Text Decoder Model: gpt2
Dataset used: MSR-VTT
Results:
Epoch 1 finished with average loss: 3.8702
Epoch 2 finished with average loss: 3.2515
Epoch 3 finished with average loss: 2.8516
Example Inference Code:
import av
import numpy as np
import torch
from transformers import AutoImageProcessor, AutoTokenizer, VisionEncoderDecoderModel
device = "cuda" if torch.cuda.is_available() else "cpu"
# load pretrained processor, tokenizer, and model
image_processor = AutoImageProcessor.from_pretrained("notbdq/videogpt")
tokenizer = AutoTokenizer.from_pretrained("notbdq/videogpt")
model = VisionEncoderDecoderModel.from_pretrained("notbdq/videogpt").to(device)
video_path = "/kaggle/input/darthvader1/darthvadersurfing.mp4"
container = av.open(video_path)
# extract evenly spaced frames from video
seg_len = container.streams.video[0].frames
clip_len = model.config.encoder.num_frames
indices = set(np.linspace(0, seg_len, num=clip_len, endpoint=False).astype(np.int64))
frames = []
container.seek(0)
for i, frame in enumerate(container.decode(video=0)):
if i in indices:
frames.append(frame.to_ndarray(format="rgb24"))
# generate caption
gen_kwargs = {
"max_length": 20,
}
pixel_values = image_processor(frames, return_tensors="pt").pixel_values.to(device)
tokens = model.generate(pixel_values, **gen_kwargs)
caption = tokenizer.batch_decode(tokens, skip_special_tokens=True)[0]
print(caption) # man is surfing in the ocean and doing tricks on a surfboard
Author Information:
- Downloads last month
- 3
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐ 1 Ask for provider support
docker model run hf.co/notbdq/videogpt