|
|
import spaces |
|
|
import gradio as gr |
|
|
from transformers import pipeline |
|
|
from PIL import Image |
|
|
|
|
|
|
|
|
pipe = pipeline("image-to-text", model="google/pix2struct-screen2words-large") |
|
|
|
|
|
@spaces.GPU |
|
|
def describe_ui(image): |
|
|
outputs = pipe(image, text="describe this image.") |
|
|
return outputs[0]['generated_text'] |
|
|
|
|
|
|
|
|
gr.Interface( |
|
|
fn=describe_ui, |
|
|
inputs=gr.Image(type="pil"), |
|
|
outputs="text", |
|
|
title="UI Screen Describer (Pix2Struct)", |
|
|
description="Upload a screenshot or UI image and get an automatic description powered by Google’s Pix2Struct model." |
|
|
).launch() |
|
|
|