File size: 521 Bytes
5dadc71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen-VL", device_map="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen-VL", trust_remote_code=True)

def analyze_image(image, prompt):
    response = model.chat(tokenizer, query=prompt, image=image)
    return response

gr.Interface(
    fn=analyze_image,
    inputs=[gr.Image(type="filepath"), gr.Textbox(label="Prompt")],
    outputs="text"
).launch()