Views
No views yet

karakuri-rd@karakuri.aipip install transformers accelerate qwen-vl-utils[decord]==0.0.81from transformers import AutoModelForImageTextToText, AutoProcessor
2from qwen_vl_utils import process_vision_info
3
4model_name = "karakuri-ai/karakuri-vl-32b-instruct-2507"
5model = AutoModelForImageTextToText.from_pretrained(
6 model_name, torch_dtype="auto", device_map="auto"
7)
8processor = AutoProcessor.from_pretrained(model_name)
9
10messages = [
11 {
12 "role": "user",
13 "content": [
14 {
15 "type": "image",
16 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
17 },
18 {"type": "text", "text": "Describe this image."},
19 ],
20 }
21]
22
23# Preparation for inference
24text = processor.apply_chat_template(
25 messages, tokenize=False, add_generation_prompt=True
26)
27image_inputs, video_inputs = process_vision_info(messages)
28inputs = processor(
29 text=[text],
30 images=image_inputs,
31 videos=video_inputs,
32 padding=True,
33 return_tensors="pt",
34)
35inputs = inputs.to(model.device)
36
37# Inference: Generation of the output
38generated_ids = model.generate(**inputs, max_new_tokens=128)
39generated_ids_trimmed = [
40 out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
41]
42output_text = processor.batch_decode(
43 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
44)
45print(output_text)@misc{karakuri_vl_32b_instruct_2507,
author = { {KARAKURI} {Inc.} },
title = { {KARAKURI} {VL} 32{B} {Instruct} 2507 },
year = { 2025 },
url = { https://huggingface.co/karakuri-ai/karakuri-vl-32b-instruct-2507 },
publisher = { {Hugging Face} },
journal = { {Hugging Face} repository }
}