Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
-
from PIL import Image
|
3 |
from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
|
4 |
|
5 |
model = Pix2StructForConditionalGeneration.from_pretrained("google/pix2struct-docvqa-large")
|
6 |
processor = Pix2StructProcessor.from_pretrained("google/pix2struct-docvqa-large")
|
7 |
|
8 |
def process_document(image, question):
|
9 |
-
image = Image.open(image)
|
10 |
inputs = processor(images=image, text=question, return_tensors="pt")
|
11 |
predictions = model.generate(**inputs)
|
12 |
return processor.decode(predictions[0], skip_special_tokens=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
# from PIL import Image
|
3 |
from transformers import Pix2StructForConditionalGeneration, Pix2StructProcessor
|
4 |
|
5 |
model = Pix2StructForConditionalGeneration.from_pretrained("google/pix2struct-docvqa-large")
|
6 |
processor = Pix2StructProcessor.from_pretrained("google/pix2struct-docvqa-large")
|
7 |
|
8 |
def process_document(image, question):
|
9 |
+
# image = Image.open(image)
|
10 |
inputs = processor(images=image, text=question, return_tensors="pt")
|
11 |
predictions = model.generate(**inputs)
|
12 |
return processor.decode(predictions[0], skip_special_tokens=True)
|