Views
No views yet
1
2from transformers import Qwen3VLMoeForConditionalGeneration, AutoProcessor
3
4# default: Load the model on the available device(s)
5model_name = "Intel/Qwen3-VL-30B-A3B-Instruct-int4-AutoRound"
6model = Qwen3VLMoeForConditionalGeneration.from_pretrained(
7 model_name, dtype="auto", device_map="auto"
8)
9
10processor = AutoProcessor.from_pretrained(model_name)
11
12messages = [
13 {
14 "role": "user",
15 "content": [
16 {
17 "type": "image",
18 "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
19 },
20 {"type": "text", "text": "Describe this image."},
21 ],
22 }
23]
24
25# Preparation for inference
26inputs = processor.apply_chat_template(
27 messages,
28 tokenize=True,
29 add_generation_prompt=True,
30 return_dict=True,
31 return_tensors="pt"
32)
33
34# Inference: Generation of the output
35generated_ids = model.generate(**inputs, max_new_tokens=128)
36generated_ids_trimmed = [
37 out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
38]
39output_text = processor.batch_decode(
40 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
41)
42print(output_text)
43"""
44This is a heartwarming and serene photograph capturing a moment of connection between a woman and her dog on a beach at sunset.
45\n\nThe image is taken from a side angle, focusing on the interaction between the two subjects. A woman with long, dark hair is sitting on the sand,
46turned towards a large, light-colored dog, likely a yellow Labrador Retriever. The dog is sitting upright and is actively engaging with the woman,
47extending its right front paw to give her a "high five." The woman is smiling warmly, looking at the dog with affection as she reciprocates the gesture.
48\n\nThe setting is a sandy beach with gentle
49"""1python3 -m vllm.entrypoints.openai.api_server \
2 --host localhost \
3 --port 4321 \
4 --trust-remote-code \
5 --model Intel/Qwen3-VL-30B-A3B-Instruct-int4-AutoRound \
6 --tensor-parallel-size 1
71curl --noproxy '*' http://127.0.0.1:4321/v1/chat/completions \
2 -H "Content-Type: application/json" \
3 -d '{
4 "model": "Intel/Qwen3-VL-30B-A3B-Instruct-int4-AutoRound",
5 "messages": [
6 {
7 "role": "user",
8 "content": [
9 { "type": "text", "text": "Describe this image." },
10 {
11 "type": "image_url",
12 "image_url": {
13 "url": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
14 }
15 }
16 ]
17 }
18 ],
19 "max_tokens": 256,
20 "temperature": 0.6
21 }'
22
23"""
24This is a heartwarming, full-shot photograph capturing a joyful moment between a woman and her dog on a beach at sunset.
25\n\n- **Subjects and Interaction**: The central focus is a woman and a light-colored Labrador Retriever sitting on the sand.
26 The woman, with long dark hair, is smiling warmly as she looks at her dog. The dog, wearing a blue harness with a colorful pattern,
27 is sitting upright and has its right paw raised to meet the woman's hand in a \"high-five\" gesture. The woman is holding a small treat in her other hand,
28 suggesting a moment of training or play.\n- **Setting and Atmosphere**: The scene is set on a wide, sandy beach with the ocean in the background.
29 A gentle wave is breaking on the shore. The lighting is characteristic of a golden hour, with the sun low on the horizon,
30 casting a warm, soft glow across the scene and creating a lens flare on the right side of the image. The sky is bright and hazy,
31 indicating the time is either sunrise or sunset.\n- **Composition and Mood**: The woman and dog are positioned in the center of the frame,
32 creating a balanced and intimate composition. The overall mood is one of happiness, companionship, and peaceful connection with nature.
33"""1auto_round \
2--model=Qwen/Qwen3-VL-30B-A3B-Instruct \
3--fp_layers=mlp.gate \
4--format=auto_round \
5--output_dir=./tmp_autoround