mp-02 commited on
Commit
fc77b97
1 Parent(s): 562d507

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -5,11 +5,11 @@ import json
5
 
6
  def prediction(image):
7
 
8
- # we first use the model fine-tuned on sroie (for now it is Theivaprakasham/layoutlmv3-finetuned-sroie)
9
- # on the image, which gives us a JSON with some info and we blur the corresponding boxes
10
  j1, image_blurred = sroie_prediction(image)
11
 
12
- # then we 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,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
- # we use a gradio interface that takes in input an image and return a JSON file that contains its info
32
- # we show also the intermediate steps (first we take some info with the model fine-tuned on SROIE and we blur the relative boxes
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"),