File size: 687 Bytes
39c275b
 
 
6fd6f53
39c275b
6fd6f53
39c275b
6fd6f53
39c275b
6fd6f53
39c275b
 
 
 
1daeec9
39c275b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import gradio as gr
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
from peft import PeftModel
import spaces

@spaces.GPU
def greet(image, prompt):
    base_model = PaliGemmaForConditionalGeneration.from_pretrained("google/paligemma-3b-mix-224")
    processor = AutoProcessor.from_pretrained("google/paligemma-3b-mix-224")
    model = PeftModel(base_model, "/folders")
    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()