Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import torch, os, json, requests
|
| 3 |
from PIL import Image
|
| 4 |
from transformers import DonutProcessor, VisionEncoderDecoderModel, VisionEncoderDecoderConfig
|
| 5 |
from torchvision import transforms
|
|
@@ -51,6 +51,8 @@ class OCRVQAModel(torch.nn.Module):
|
|
| 51 |
# try:
|
| 52 |
self.donut.eval()
|
| 53 |
with torch.no_grad():
|
|
|
|
|
|
|
| 54 |
image_ids = self.processor(image, return_tensors="pt").pixel_values.to(device)
|
| 55 |
|
| 56 |
question = f'<s_docvqa><s_question>{prompt}</s_question><s_answer>'
|
|
@@ -120,7 +122,6 @@ with gr.Blocks() as demo:
|
|
| 120 |
image_url = gr.Textbox(lines=1, label="Image URL", placeholder="Or, paste the image URL here")
|
| 121 |
question = gr.Textbox(lines=5, label="Question")
|
| 122 |
|
| 123 |
-
with gr.Column():
|
| 124 |
ask = gr.Button(label="Get the answer")
|
| 125 |
|
| 126 |
with gr.Column():
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch, os, json, requests, sys
|
| 3 |
from PIL import Image
|
| 4 |
from transformers import DonutProcessor, VisionEncoderDecoderModel, VisionEncoderDecoderConfig
|
| 5 |
from torchvision import transforms
|
|
|
|
| 51 |
# try:
|
| 52 |
self.donut.eval()
|
| 53 |
with torch.no_grad():
|
| 54 |
+
|
| 55 |
+
print(type(image), type(prompt), file = sys.stderr)
|
| 56 |
image_ids = self.processor(image, return_tensors="pt").pixel_values.to(device)
|
| 57 |
|
| 58 |
question = f'<s_docvqa><s_question>{prompt}</s_question><s_answer>'
|
|
|
|
| 122 |
image_url = gr.Textbox(lines=1, label="Image URL", placeholder="Or, paste the image URL here")
|
| 123 |
question = gr.Textbox(lines=5, label="Question")
|
| 124 |
|
|
|
|
| 125 |
ask = gr.Button(label="Get the answer")
|
| 126 |
|
| 127 |
with gr.Column():
|