Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,19 +6,19 @@ import json
|
|
6 |
def prediction(image):
|
7 |
|
8 |
#we first use mp-02/layoutlmv3-finetuned-cord on the image, which gives us a JSON with some info and a blurred image
|
9 |
-
|
10 |
|
11 |
#then we use the model fine-tuned on sroie (for now it is Theivaprakasham/layoutlmv3-finetuned-sroie)
|
12 |
-
|
13 |
-
j2, image_final = cord_prediction(
|
14 |
|
15 |
#we then link the two json files
|
16 |
-
if len(
|
17 |
j3 = j2
|
18 |
else:
|
19 |
-
j3 = json.dumps(
|
20 |
|
21 |
-
return
|
22 |
|
23 |
|
24 |
title = "Interactive demo: LayoutLMv3 for receipts"
|
|
|
6 |
def prediction(image):
|
7 |
|
8 |
#we first use mp-02/layoutlmv3-finetuned-cord on the image, which gives us a JSON with some info and a blurred image
|
9 |
+
j1, image_blurred = sroie_prediction(image)
|
10 |
|
11 |
#then we use the model fine-tuned on sroie (for now it is Theivaprakasham/layoutlmv3-finetuned-sroie)
|
12 |
+
img = image_blurred.copy()
|
13 |
+
j2, image_final = cord_prediction(img)
|
14 |
|
15 |
#we then link the two json files
|
16 |
+
if len(j1) == 0:
|
17 |
j3 = j2
|
18 |
else:
|
19 |
+
j3 = json.dumps(j1).split('}')[0] + ', ' + json.dumps(j2).split('{')[1]
|
20 |
|
21 |
+
return j1, image_blurred, j2, image_final, j3
|
22 |
|
23 |
|
24 |
title = "Interactive demo: LayoutLMv3 for receipts"
|