Update app.py
Browse files
app.py
CHANGED
|
@@ -509,45 +509,45 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {background-color:
|
|
| 509 |
|
| 510 |
|
| 511 |
# -- Bloc 2 - ID Extraction
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
|
| 523 |
# Ouvrir l'image avec PIL
|
| 524 |
-
|
| 525 |
|
| 526 |
# Appeler la fonction d'extraction
|
| 527 |
-
|
| 528 |
|
| 529 |
-
|
| 530 |
-
with gr.Column(visible=True) as id_extraction_block:
|
| 531 |
-
|
| 532 |
|
| 533 |
# Image input via webcam ou fichier
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
id_output = gr.Textbox(label="Résultat", lines=10)
|
| 542 |
-
id_button = gr.Button("📤 Extraire les informations")
|
| 543 |
-
|
| 544 |
-
def extract_id_fn(image):
|
| 545 |
-
if image is None:
|
| 546 |
-
return "❌ Aucune image reçue."
|
| 547 |
|
| 548 |
-
|
|
|
|
| 549 |
|
| 550 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 551 |
|
| 552 |
|
| 553 |
# -- Bloc 3 - Car Detection
|
|
|
|
| 509 |
|
| 510 |
|
| 511 |
# -- Bloc 2 - ID Extraction
|
| 512 |
+
with gr.Column(visible=False) as id_extraction_block:
|
| 513 |
+
gr.Markdown("🪪 **Extraction d'informations d'identité à partir d'image**")
|
| 514 |
+
id_image_input = gr.File(label="Uploader image de pièce d'identité", file_types=["image"], file_count="multiple")
|
| 515 |
+
id_output = gr.Textbox(label="Résultat", lines=6)
|
| 516 |
+
id_button = gr.Button("📤 Extraire les informations")
|
| 517 |
+
|
| 518 |
+
def extract_id_fn(files):
|
| 519 |
+
if not files:
|
| 520 |
+
return "❌ Aucun fichier reçu."
|
| 521 |
+
file_path = files[0]
|
| 522 |
|
| 523 |
# Ouvrir l'image avec PIL
|
| 524 |
+
image = Image.open(file_path)
|
| 525 |
|
| 526 |
# Appeler la fonction d'extraction
|
| 527 |
+
return extract_identity_card_info(image)
|
| 528 |
|
| 529 |
+
id_button.click(fn=extract_id_fn, inputs=[id_image_input], outputs=[id_output])
|
| 530 |
+
#with gr.Column(visible=True) as id_extraction_block:
|
| 531 |
+
# gr.Markdown("🪪 **Extraction d'informations d'identité à partir d'image**")
|
| 532 |
|
| 533 |
# Image input via webcam ou fichier
|
| 534 |
+
# id_image_input = gr.Image(
|
| 535 |
+
# label="📷 Prendre ou uploader une image",
|
| 536 |
+
# source="upload", # Remplace par "webcam" pour forcer la caméra
|
| 537 |
+
# tool=None,
|
| 538 |
+
# type="pil" # Image sera passée directement comme objet PIL
|
| 539 |
+
# )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
|
| 541 |
+
# id_output = gr.Textbox(label="Résultat", lines=10)
|
| 542 |
+
# id_button = gr.Button("📤 Extraire les informations")
|
| 543 |
|
| 544 |
+
# def extract_id_fn(image):
|
| 545 |
+
# if image is None:
|
| 546 |
+
# return "❌ Aucune image reçue."
|
| 547 |
+
#
|
| 548 |
+
# return extract_identity_card_info(image)
|
| 549 |
+
#
|
| 550 |
+
# id_button.click(fn=extract_id_fn, inputs=[id_image_input], outputs=[id_output])
|
| 551 |
|
| 552 |
|
| 553 |
# -- Bloc 3 - Car Detection
|