Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import Pix2StructProcessor, Pix2StructForConditionalGeneration
|
| 3 |
from PIL import Image
|
|
@@ -7,6 +8,7 @@ model = Pix2StructForConditionalGeneration.from_pretrained("google/pix2struct-sc
|
|
| 7 |
processor = Pix2StructProcessor.from_pretrained("google/pix2struct-screen2words-large")
|
| 8 |
|
| 9 |
# Define the function
|
|
|
|
| 10 |
def describe_ui(image):
|
| 11 |
inputs = processor(images=image, return_tensors="pt")
|
| 12 |
outputs = model.generate(**inputs)
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import Pix2StructProcessor, Pix2StructForConditionalGeneration
|
| 4 |
from PIL import Image
|
|
|
|
| 8 |
processor = Pix2StructProcessor.from_pretrained("google/pix2struct-screen2words-large")
|
| 9 |
|
| 10 |
# Define the function
|
| 11 |
+
@spaces.GPU
|
| 12 |
def describe_ui(image):
|
| 13 |
inputs = processor(images=image, return_tensors="pt")
|
| 14 |
outputs = model.generate(**inputs)
|