Update app.py
Browse files
app.py
CHANGED
|
@@ -7,12 +7,13 @@ from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
|
|
| 7 |
|
| 8 |
# Load model and processor
|
| 9 |
model = Pix2StructForConditionalGeneration.from_pretrained("google/pix2struct-screen2words-large", dtype=torch.bfloat16).to("cuda")
|
|
|
|
| 10 |
processor = Pix2StructProcessor.from_pretrained("google/pix2struct-screen2words-large")
|
| 11 |
|
| 12 |
# Define the function
|
| 13 |
@spaces.GPU
|
| 14 |
def describe_ui(image):
|
| 15 |
-
inputs = processor(images=image, text="describe this image: ", return_tensors="pt")
|
| 16 |
predictions = model.generate(**inputs)
|
| 17 |
return processor.decode(predictions[0], skip_special_tokens=True)
|
| 18 |
|
|
|
|
| 7 |
|
| 8 |
# Load model and processor
|
| 9 |
model = Pix2StructForConditionalGeneration.from_pretrained("google/pix2struct-screen2words-large", dtype=torch.bfloat16).to("cuda")
|
| 10 |
+
model.eval()
|
| 11 |
processor = Pix2StructProcessor.from_pretrained("google/pix2struct-screen2words-large")
|
| 12 |
|
| 13 |
# Define the function
|
| 14 |
@spaces.GPU
|
| 15 |
def describe_ui(image):
|
| 16 |
+
inputs = processor(images=image, text="describe this image: ", return_tensors="pt").to("cuda")
|
| 17 |
predictions = model.generate(**inputs)
|
| 18 |
return processor.decode(predictions[0], skip_special_tokens=True)
|
| 19 |
|