triphuong57's picture
Update app.py
1daeec9 verified
raw
history blame
614 Bytes
import gradio as gr
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
from peft import PeftModel
def greet(image, prompt):
model = PaliGemmaForConditionalGeneration.from_pretrained("triphuong57/paligemma_finetune")
processor = AutoProcessor.from_pretrained("google/paligemma-3b-mix-224")
inputs = processor(prompt, raw_image, return_tensors="pt")
output = model.generate(**inputs, max_new_tokens=20)
return output
demo = gr.Interface(fn=greet, inputs=[gr.Image(label="Upload image", sources=['upload', 'webcam'], type="pil"), gr.Text()], outputs="text")
demo.launch()