Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,16 @@
|
|
| 1 |
import spaces
|
| 2 |
import gradio as gr
|
| 3 |
-
from transformers import
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
# Load model and processor
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
# Define the function
|
| 11 |
@spaces.GPU
|
| 12 |
def describe_ui(image):
|
| 13 |
-
|
| 14 |
-
outputs
|
| 15 |
-
return processor.decode(outputs[0], skip_special_tokens=True)
|
| 16 |
|
| 17 |
# Launch the Gradio interface
|
| 18 |
gr.Interface(
|
|
|
|
| 1 |
import spaces
|
| 2 |
import gradio as gr
|
| 3 |
+
from transformers import pipeline
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
# Load model and processor
|
| 7 |
+
pipe = pipeline("image-to-text", model="google/pix2struct-screen2words-large")
|
| 8 |
+
pipe.to('cuda')
|
|
|
|
| 9 |
# Define the function
|
| 10 |
@spaces.GPU
|
| 11 |
def describe_ui(image):
|
| 12 |
+
outputs = pipe(image)
|
| 13 |
+
return outputs[0]['generated_text']
|
|
|
|
| 14 |
|
| 15 |
# Launch the Gradio interface
|
| 16 |
gr.Interface(
|