Update app.py
Browse files
app.py
CHANGED
@@ -16,9 +16,8 @@ model = VisionEncoderDecoderModel.from_pretrained("./donut-base-finetuned-inv")
|
|
16 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
17 |
model.to(device)
|
18 |
|
19 |
-
state = "start_or_clear"
|
20 |
|
21 |
-
def update_status(
|
22 |
if state == "start_or_clear":
|
23 |
state = 'processing' #current state becomes
|
24 |
return (gr.update(value="snowangel.gif",visible=True),gr.update(value="snowangel.gif",visible=True))
|
@@ -91,6 +90,7 @@ css = "#inp {height: auto !important; width: 100% !important;}"
|
|
91 |
|
92 |
|
93 |
with gr.Blocks(css=css) as demo:
|
|
|
94 |
|
95 |
gr.HTML(title)
|
96 |
gr.HTML(paragraph1)
|
@@ -114,7 +114,7 @@ with gr.Blocks(css=css) as demo:
|
|
114 |
imgout = gr.Image(label='Uploaded document:',elem_id="inp")
|
115 |
with gr.Column(scale=1):
|
116 |
jsonout = gr.JSON(label='Extracted information:')
|
117 |
-
imgout.change(fn=update_status,inputs=
|
118 |
btn.click(fn=process_document, inputs=inp, outputs=[jsonout,imgout])
|
119 |
|
120 |
demo.launch()
|
|
|
16 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
17 |
model.to(device)
|
18 |
|
|
|
19 |
|
20 |
+
def update_status(state):
|
21 |
if state == "start_or_clear":
|
22 |
state = 'processing' #current state becomes
|
23 |
return (gr.update(value="snowangel.gif",visible=True),gr.update(value="snowangel.gif",visible=True))
|
|
|
90 |
|
91 |
|
92 |
with gr.Blocks(css=css) as demo:
|
93 |
+
state = gr.State(value='start_or_clear')
|
94 |
|
95 |
gr.HTML(title)
|
96 |
gr.HTML(paragraph1)
|
|
|
114 |
imgout = gr.Image(label='Uploaded document:',elem_id="inp")
|
115 |
with gr.Column(scale=1):
|
116 |
jsonout = gr.JSON(label='Extracted information:')
|
117 |
+
imgout.change(fn=update_status,inputs=state,outputs=[img2,img3])
|
118 |
btn.click(fn=process_document, inputs=inp, outputs=[jsonout,imgout])
|
119 |
|
120 |
demo.launch()
|