Editing
Multimodal AI
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Visual question answering with a vision-language model (Qwen2-VL):''' <syntaxhighlight lang="python"> from transformers import Qwen2VLForConditionalGeneration, AutoProcessor from PIL import Image import requests # Load model and processor model = Qwen2VLForConditionalGeneration.from_pretrained( "Qwen/Qwen2-VL-7B-Instruct", torch_dtype="auto", device_map="auto" ) processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-7B-Instruct") # Load image image = Image.open("chart.png") # Build multimodal conversation messages = [ { "role": "user", "content": [ {"type": "image", "image": image}, {"type": "text", "text": "What trend does this chart show? " "Which year had the highest value?"} ] } ] # Process and generate text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device) output_ids = model.generate(**inputs, max_new_tokens=512) response = processor.batch_decode(output_ids, skip_special_tokens=True)[0] print(response) </syntaxhighlight> ; Multimodal task β model mapping : '''Image + text understanding''' β GPT-4o, Gemini 1.5, Claude 3, LLaVA-1.6 : '''Text-to-image generation''' β DALL-E 3, Stable Diffusion XL, Flux.1, Midjourney : '''Speech recognition (ASR)''' β Whisper (OpenAI), SeamlessM4T : '''Text-to-speech (TTS)''' β ElevenLabs, Bark, Kokoro : '''Video understanding''' β Gemini 1.5 Pro, Video-LLaMA, LLaVA-Video : '''Cross-modal retrieval''' β CLIP, SigLIP, OpenCLIP : '''Document understanding (OCR + reasoning)''' β Qwen2-VL, GOT-OCR, Donut </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information