| import gradio as gr |
| import os |
| from utils import extraire_informations_carte,make_prediction |
|
|
| def predict(img): |
| proba, document_type = make_prediction(img) |
| if proba < .98: |
| return "Ce document ne fait pas partir de ceux pris en charge actuelement (Nouvelle et Ancienne CNI, Permis de conduire)" |
| else : |
| doc_type = document_type +1 |
| result = extraire_informations_carte(img,doc_type) |
| return result |
|
|
| image = gr.components.Image(type = "filepath") |
| |
| out_lab = gr.components.Textbox() |
|
|
| |
| |
| title = "OCR FOR IMAGES ANALYSIS" |
| description = "WE USE OCR TO EXTRACT INFORMATIONS FROM DIFFERENT TYPES OF DOCUMENTS AND FORMALIZE THE RESULT INTO JSON." |
| article = "Created by data354." |
|
|
| |
| example_list = [["examples/" + example] for example in os.listdir("examples")] |
| print(example_list) |
| |
| |
| |
| |
| demo = gr.Interface(fn=predict, |
| inputs= image, |
| outputs=out_lab, |
| examples=example_list, |
| title=title, |
| description=description, |
| article=article |
| ) |
| |
| demo.launch(debug = True) |