Spaces:
Runtime error
Runtime error
File size: 725 Bytes
a5458c0 12f4f6d a5458c0 12f4f6d a5458c0 12f4f6d a5458c0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import gradio as gr
from transformers import AutoProcessor, PaliGemmaForConditionalGeneration
from peft import PeftModel
import spaces
device = "cuda"
@spaces.GPU
def greet(image, prompt):
base_model = PaliGemmaForConditionalGeneration.from_pretrained("google/paligemma-3b-mix-224").to(device)
processor = AutoProcessor.from_pretrained("google/paligemma-3b-mix-224")
model = PeftModel(base_model, "/folders").to(device)
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() |