Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,11 @@ import json
|
|
5 |
|
6 |
def prediction(image):
|
7 |
|
8 |
-
#
|
9 |
-
# on the image, which
|
10 |
j1, image_blurred = sroie_prediction(image)
|
11 |
|
12 |
-
# then
|
13 |
img = image_blurred.copy()
|
14 |
j2, image_final = cord_prediction(img)
|
15 |
|
@@ -24,13 +24,12 @@ def prediction(image):
|
|
24 |
|
25 |
title = "Interactive demo: LayoutLMv3 for receipts"
|
26 |
description = "Demo for Microsoft's LayoutLMv3, a Transformer for state-of-the-art document image understanding tasks. This particular space uses two instances of the model, one fine-tuned on CORD and the other SROIE.\n It firsts uses the fine-tune on SROIE to extract date, company and address, then the fine-tune on CORD for the other info. To use it, simply upload an image or use the example image below. Results will show up in a few seconds."
|
27 |
-
examples = [['image.jpeg']['image.png']]
|
28 |
|
29 |
css = """.output_image, .input_image {height: 600px !important}"""
|
30 |
|
31 |
-
#
|
32 |
-
#
|
33 |
-
# then we pass the image to the model fine-tuned on CORD
|
34 |
iface = gr.Interface(fn=prediction,
|
35 |
inputs=gr.Image(type="pil"),
|
36 |
outputs=[gr.JSON(label="json parsing"),
|
|
|
5 |
|
6 |
def prediction(image):
|
7 |
|
8 |
+
# first use the model fine-tuned on sroie (for now it is Theivaprakasham/layoutlmv3-finetuned-sroie)
|
9 |
+
# on the image, which returns a JSON with some info and an image with the corresponding boxes blurred
|
10 |
j1, image_blurred = sroie_prediction(image)
|
11 |
|
12 |
+
# then use the model fine-tuned on cord on the blurred image
|
13 |
img = image_blurred.copy()
|
14 |
j2, image_final = cord_prediction(img)
|
15 |
|
|
|
24 |
|
25 |
title = "Interactive demo: LayoutLMv3 for receipts"
|
26 |
description = "Demo for Microsoft's LayoutLMv3, a Transformer for state-of-the-art document image understanding tasks. This particular space uses two instances of the model, one fine-tuned on CORD and the other SROIE.\n It firsts uses the fine-tune on SROIE to extract date, company and address, then the fine-tune on CORD for the other info. To use it, simply upload an image or use the example image below. Results will show up in a few seconds."
|
27 |
+
examples = [['image.jpeg'],['image.png']]
|
28 |
|
29 |
css = """.output_image, .input_image {height: 600px !important}"""
|
30 |
|
31 |
+
# gradio interface that takes in input an image and return a JSON file that contains its info
|
32 |
+
# for now it shows also the intermediate steps
|
|
|
33 |
iface = gr.Interface(fn=prediction,
|
34 |
inputs=gr.Image(type="pil"),
|
35 |
outputs=[gr.JSON(label="json parsing"),
|