Spaces:
Sleeping
Sleeping
update app
Browse files
app.py
CHANGED
@@ -1,19 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
-
from utils import extraire_informations_carte
|
4 |
-
|
5 |
-
def predict(img, type_doc):
|
6 |
-
data = {"Nouvelle_CNI":1,"ANCIENNE_CNI":2,"PERMIS_DE_CONDUITE":3}
|
7 |
-
type_document = data[type_doc]
|
8 |
-
result = extraire_informations_carte(img,type_document)
|
9 |
-
return result
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
image = gr.components.Image(type = "filepath")
|
16 |
-
type_document = gr.components.Dropdown(["Nouvelle_CNI","ANCIENNE_CNI","PERMIS_DE_CONDUITE"])
|
17 |
out_lab = gr.components.Textbox()
|
18 |
|
19 |
### 4. Gradio app ###
|
@@ -23,15 +22,15 @@ description = "WE USE OCR TO EXTRACT INFORMATIONS FROM DIFFERENT TYPES OF DOCUME
|
|
23 |
article = "Created by data354."
|
24 |
|
25 |
# Create examples list from "examples/" directory
|
26 |
-
example_list = [["examples/" + example
|
27 |
print(example_list)
|
28 |
#[gr.Label(label="Predictions"), # what are the outputs?
|
29 |
#gr.Number(label="Prediction time (s)")], # our fn has two outputs, therefore we have two outputs
|
30 |
# Create examples list from "examples/" directory
|
31 |
# Create the Gradio demo
|
32 |
demo = gr.Interface(fn=predict, # mapping function from input to output
|
33 |
-
inputs=
|
34 |
-
outputs=out_lab,
|
35 |
examples=example_list,
|
36 |
title=title,
|
37 |
description=description,
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
from utils import extraire_informations_carte,make_prediction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
def predict(img):
|
6 |
+
proba, document_type = make_prediction(img)
|
7 |
+
if proba < .98:
|
8 |
+
return "Ce document ne fait pas partir de ceux pris en charge actuelement (Nouvelle et Ancienne CNI, Permis de conduire)"
|
9 |
+
else :
|
10 |
+
doc_type = document_type +1
|
11 |
+
result = extraire_informations_carte(img,doc_type)
|
12 |
+
return result
|
13 |
|
14 |
image = gr.components.Image(type = "filepath")
|
15 |
+
#type_document = gr.components.Dropdown(["Nouvelle_CNI","ANCIENNE_CNI","PERMIS_DE_CONDUITE"])
|
16 |
out_lab = gr.components.Textbox()
|
17 |
|
18 |
### 4. Gradio app ###
|
|
|
22 |
article = "Created by data354."
|
23 |
|
24 |
# Create examples list from "examples/" directory
|
25 |
+
example_list = [["examples/" + example] for example in os.listdir("examples")]
|
26 |
print(example_list)
|
27 |
#[gr.Label(label="Predictions"), # what are the outputs?
|
28 |
#gr.Number(label="Prediction time (s)")], # our fn has two outputs, therefore we have two outputs
|
29 |
# Create examples list from "examples/" directory
|
30 |
# Create the Gradio demo
|
31 |
demo = gr.Interface(fn=predict, # mapping function from input to output
|
32 |
+
inputs= image, #gr.Image(type="pil"), # what are the inputs?
|
33 |
+
outputs=out_lab, #[list of outputs]
|
34 |
examples=example_list,
|
35 |
title=title,
|
36 |
description=description,
|