zai-org / cogvlm2-llama3-caption

huggingface.co
Total runs: 241
24-hour runs: -42
7-day runs: -73
30-day runs: -295
Model's Last Updated: May 14 2025
video-text-to-text

Introduction of cogvlm2-llama3-caption

Model Details of cogvlm2-llama3-caption

中文阅读

CogVLM2-Llama3-Caption

Code | 🤗 Hugging Face | 🤖 ModelScope

Typically, most video data does not come with corresponding descriptive text, so it is necessary to convert the video data into textual descriptions to provide the essential training data for text-to-video models. CogVLM2-Caption is a video captioning model used to generate training data for the CogVideoX model.

Usage
import io

import argparse
import numpy as np
import torch
from decord import cpu, VideoReader, bridge
from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_PATH = "THUDM/cogvlm2-llama3-caption"

DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
TORCH_TYPE = torch.bfloat16 if torch.cuda.is_available() and torch.cuda.get_device_capability()[
    0] >= 8 else torch.float16

parser = argparse.ArgumentParser(description="CogVLM2-Video CLI Demo")
parser.add_argument('--quant', type=int, choices=[4, 8], help='Enable 4-bit or 8-bit precision loading', default=0)
args = parser.parse_args([])


def load_video(video_data, strategy='chat'):
    bridge.set_bridge('torch')
    mp4_stream = video_data
    num_frames = 24
    decord_vr = VideoReader(io.BytesIO(mp4_stream), ctx=cpu(0))

    frame_id_list = None
    total_frames = len(decord_vr)
    if strategy == 'base':
        clip_end_sec = 60
        clip_start_sec = 0
        start_frame = int(clip_start_sec * decord_vr.get_avg_fps())
        end_frame = min(total_frames,
                        int(clip_end_sec * decord_vr.get_avg_fps())) if clip_end_sec is not None else total_frames
        frame_id_list = np.linspace(start_frame, end_frame - 1, num_frames, dtype=int)
    elif strategy == 'chat':
        timestamps = decord_vr.get_frame_timestamp(np.arange(total_frames))
        timestamps = [i[0] for i in timestamps]
        max_second = round(max(timestamps)) + 1
        frame_id_list = []
        for second in range(max_second):
            closest_num = min(timestamps, key=lambda x: abs(x - second))
            index = timestamps.index(closest_num)
            frame_id_list.append(index)
            if len(frame_id_list) >= num_frames:
                break

    video_data = decord_vr.get_batch(frame_id_list)
    video_data = video_data.permute(3, 0, 1, 2)
    return video_data


tokenizer = AutoTokenizer.from_pretrained(
    MODEL_PATH,
    trust_remote_code=True,
)

model = AutoModelForCausalLM.from_pretrained(
    MODEL_PATH,
    torch_dtype=TORCH_TYPE,
    trust_remote_code=True
).eval().to(DEVICE)


def predict(prompt, video_data, temperature):
    strategy = 'chat'

    video = load_video(video_data, strategy=strategy)

    history = []
    query = prompt
    inputs = model.build_conversation_input_ids(
        tokenizer=tokenizer,
        query=query,
        images=[video],
        history=history,
        template_version=strategy
    )
    inputs = {
        'input_ids': inputs['input_ids'].unsqueeze(0).to('cuda'),
        'token_type_ids': inputs['token_type_ids'].unsqueeze(0).to('cuda'),
        'attention_mask': inputs['attention_mask'].unsqueeze(0).to('cuda'),
        'images': [[inputs['images'][0].to('cuda').to(TORCH_TYPE)]],
    }
    gen_kwargs = {
        "max_new_tokens": 2048,
        "pad_token_id": 128002,
        "top_k": 1,
        "do_sample": False,
        "top_p": 0.1,
        "temperature": temperature,
    }
    with torch.no_grad():
        outputs = model.generate(**inputs, **gen_kwargs)
        outputs = outputs[:, inputs['input_ids'].shape[1]:]
        response = tokenizer.decode(outputs[0], skip_special_tokens=True)
        return response


def test():
    prompt = "Please describe this video in detail."
    temperature = 0.1
    video_data = open('test.mp4', 'rb').read()
    response = predict(prompt, video_data, temperature)
    print(response)


if __name__ == '__main__':
    test()
License

This model is released under the CogVLM2 LICENSE . For models built with Meta Llama 3, please also adhere to the LLAMA3_LICENSE .

Citation

🌟 If you find our work helpful, please leave us a star and cite our paper.

@article{yang2024cogvideox,
  title={CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer},
  author={Yang, Zhuoyi and Teng, Jiayan and Zheng, Wendi and Ding, Ming and Huang, Shiyu and Xu, Jiazheng and Yang, Yuanming and Hong, Wenyi and Zhang, Xiaohan and Feng, Guanyu and others},
  journal={arXiv preprint arXiv:2408.06072},
  year={2024}
}

Runs of zai-org cogvlm2-llama3-caption on huggingface.co

241
Total runs
-42
24-hour runs
-41
3-day runs
-73
7-day runs
-295
30-day runs

More Information About cogvlm2-llama3-caption huggingface.co Model

More cogvlm2-llama3-caption license Visit here:

https://choosealicense.com/licenses/other

cogvlm2-llama3-caption huggingface.co

cogvlm2-llama3-caption huggingface.co is an AI model on huggingface.co that provides cogvlm2-llama3-caption's model effect (), which can be used instantly with this zai-org cogvlm2-llama3-caption model. huggingface.co supports a free trial of the cogvlm2-llama3-caption model, and also provides paid use of the cogvlm2-llama3-caption. Support call cogvlm2-llama3-caption model through api, including Node.js, Python, http.

cogvlm2-llama3-caption huggingface.co Url

https://huggingface.co/zai-org/cogvlm2-llama3-caption

zai-org cogvlm2-llama3-caption online free

cogvlm2-llama3-caption huggingface.co is an online trial and call api platform, which integrates cogvlm2-llama3-caption's modeling effects, including api services, and provides a free online trial of cogvlm2-llama3-caption, you can try cogvlm2-llama3-caption online for free by clicking the link below.

zai-org cogvlm2-llama3-caption online free url in huggingface.co:

https://huggingface.co/zai-org/cogvlm2-llama3-caption

cogvlm2-llama3-caption install

cogvlm2-llama3-caption is an open source model from GitHub that offers a free installation service, and any user can find cogvlm2-llama3-caption on GitHub to install. At the same time, huggingface.co provides the effect of cogvlm2-llama3-caption install, users can directly use cogvlm2-llama3-caption installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

cogvlm2-llama3-caption install url in huggingface.co:

https://huggingface.co/zai-org/cogvlm2-llama3-caption

Url of cogvlm2-llama3-caption

cogvlm2-llama3-caption huggingface.co Url

Provider of cogvlm2-llama3-caption huggingface.co

zai-org
ORGANIZATIONS

Other API from zai-org

huggingface.co

Total runs: 2.9M
Run Growth: 2.7M
Growth Rate: 100.00%
Updated:September 07 2026
huggingface.co

Total runs: 1.9M
Run Growth: -132.3K
Growth Rate: -7.07%
Updated:January 29 2026
huggingface.co

Total runs: 1.7M
Run Growth: -1.2M
Growth Rate: -69.39%
Updated:September 11 2026
huggingface.co

Total runs: 986.1K
Run Growth: -799.8K
Growth Rate: -77.90%
Updated:September 01 2026
huggingface.co

Total runs: 974.2K
Run Growth: -1.8M
Growth Rate: -179.50%
Updated:September 01 2026
huggingface.co

Total runs: 947.3K
Run Growth: 879.3K
Growth Rate: 99.01%
Updated:September 04 2026
huggingface.co

Total runs: 456.9K
Run Growth: -4.4K
Growth Rate: -0.97%
Updated:August 04 2024
huggingface.co

Total runs: 175.3K
Run Growth: -277.8K
Growth Rate: -148.80%
Updated:April 16 2026
huggingface.co

Total runs: 103.9K
Run Growth: 34.5K
Growth Rate: 33.00%
Updated:January 29 2026
huggingface.co

Total runs: 97.1K
Run Growth: -92.0K
Growth Rate: -89.45%
Updated:August 11 2025
huggingface.co

Total runs: 94.1K
Run Growth: -25.8K
Growth Rate: -27.92%
Updated:August 11 2025
huggingface.co

Total runs: 85.4K
Run Growth: 9.9K
Growth Rate: 11.13%
Updated:May 13 2026
huggingface.co

Total runs: 85.2K
Run Growth: -907.2K
Growth Rate: -956.07%
Updated:April 05 2026
huggingface.co

Total runs: 67.9K
Run Growth: -16.5K
Growth Rate: -24.26%
Updated:December 05 2024
huggingface.co

Total runs: 65.7K
Run Growth: -55.6K
Growth Rate: -69.34%
Updated:December 10 2025
huggingface.co

Total runs: 52.1K
Run Growth: -69.1K
Growth Rate: -122.43%
Updated:August 11 2026
huggingface.co

Total runs: 46.0K
Run Growth: -61.1K
Growth Rate: -132.26%
Updated:October 25 2025
huggingface.co

Total runs: 19.8K
Run Growth: -10.0K
Growth Rate: -52.62%
Updated:September 30 2025
huggingface.co

Total runs: 19.8K
Run Growth: -49.8K
Growth Rate: -243.71%
Updated:March 03 2025
huggingface.co

Total runs: 18.7K
Run Growth: -18.6K
Growth Rate: -97.60%
Updated:April 14 2025
huggingface.co

Total runs: 17.2K
Run Growth: 15.3K
Growth Rate: 96.94%
Updated:September 04 2026
huggingface.co

Total runs: 16.4K
Run Growth: -2.5K
Growth Rate: -15.04%
Updated:November 23 2024
huggingface.co

Total runs: 14.5K
Run Growth: -11.0K
Growth Rate: -76.42%
Updated:December 23 2025
huggingface.co

Total runs: 14.5K
Run Growth: -3.7K
Growth Rate: -25.51%
Updated:November 23 2024
huggingface.co

Total runs: 12.6K
Run Growth: 2.6K
Growth Rate: 19.33%
Updated:December 09 2025
huggingface.co

Total runs: 9.4K
Run Growth: -620
Growth Rate: -6.59%
Updated:January 15 2026
huggingface.co

Total runs: 8.3K
Run Growth: -2.0K
Growth Rate: -25.24%
Updated:October 16 2025
huggingface.co

Total runs: 6.8K
Run Growth: -1.6K
Growth Rate: -23.69%
Updated:March 11 2025
huggingface.co

Total runs: 6.8K
Run Growth: -7.1K
Growth Rate: -104.85%
Updated:April 22 2025
huggingface.co

Total runs: 4.7K
Run Growth: -3.8K
Growth Rate: -82.18%
Updated:December 09 2025
huggingface.co

Total runs: 3.2K
Run Growth: -926
Growth Rate: -29.13%
Updated:October 25 2025
huggingface.co

Total runs: 2.8K
Run Growth: 659
Growth Rate: 23.48%
Updated:August 04 2024
huggingface.co

Total runs: 2.6K
Run Growth: -6.6K
Growth Rate: -218.76%
Updated:January 27 2025
huggingface.co

Total runs: 1.9K
Run Growth: 276
Growth Rate: 16.40%
Updated:August 12 2025
huggingface.co

Total runs: 679
Run Growth: 280
Growth Rate: 41.36%
Updated:March 02 2023
huggingface.co

Total runs: 559
Run Growth: 352
Growth Rate: 64.71%
Updated:October 20 2023
huggingface.co

Total runs: 475
Run Growth: -245
Growth Rate: -52.02%
Updated:August 11 2025
huggingface.co

Total runs: 410
Run Growth: -1.0K
Growth Rate: -242.27%
Updated:January 02 2025
huggingface.co

Total runs: 397
Run Growth: 135
Growth Rate: 34.01%
Updated:December 10 2024
huggingface.co

Total runs: 356
Run Growth: -373
Growth Rate: -104.19%
Updated:October 25 2025
huggingface.co

Total runs: 272
Run Growth: 48
Growth Rate: 17.65%
Updated:November 20 2023
huggingface.co

Total runs: 259
Run Growth: 105
Growth Rate: 40.54%
Updated:October 20 2023
huggingface.co

Total runs: 251
Run Growth: 98
Growth Rate: 39.20%
Updated:October 20 2023