Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ from typing import Dict, Any, List, Union # Ajout des imports typing nécessair
|
|
22 |
import logging
|
23 |
|
24 |
# helpers functions
|
25 |
-
from helpers.rapport_generator import
|
26 |
from helpers.text_extraction import *
|
27 |
from helpers.gemini_functions import *
|
28 |
|
@@ -70,11 +70,14 @@ def process_pdf(pdf_file):
|
|
70 |
json.dump(extracted_data, f, ensure_ascii=False, indent=2)
|
71 |
|
72 |
# Generate DOCX report
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
76 |
|
77 |
-
return text_file_path, zip_path, json_path
|
78 |
|
79 |
except Exception as e:
|
80 |
raise gr.Error(f"Error processing PDF: {str(e)}")
|
@@ -105,7 +108,7 @@ demo = gr.Interface(
|
|
105 |
gr.File(label="Texte extrait (TXT)"),
|
106 |
gr.File(label="Images annotées (ZIP)"),
|
107 |
gr.File(label="Données extraites (JSON)"),
|
108 |
-
|
109 |
],
|
110 |
title="Extraction de texte PDF et création d'un rapport DOCX",
|
111 |
description="""
|
|
|
22 |
import logging
|
23 |
|
24 |
# helpers functions
|
25 |
+
from helpers.rapport_generator import *
|
26 |
from helpers.text_extraction import *
|
27 |
from helpers.gemini_functions import *
|
28 |
|
|
|
70 |
json.dump(extracted_data, f, ensure_ascii=False, indent=2)
|
71 |
|
72 |
# Generate DOCX report
|
73 |
+
try:
|
74 |
+
docx_path = os.path.join(temp_dir, "rapport_extraction.docx")
|
75 |
+
generator = RapportGenerator(json_path, docx_path)
|
76 |
+
generator.generate_report()
|
77 |
+
except Exception as e:
|
78 |
+
raise gr.Error(f"Error processing rapport: {str(e)}")
|
79 |
|
80 |
+
return text_file_path, zip_path, json_path, docx_path
|
81 |
|
82 |
except Exception as e:
|
83 |
raise gr.Error(f"Error processing PDF: {str(e)}")
|
|
|
108 |
gr.File(label="Texte extrait (TXT)"),
|
109 |
gr.File(label="Images annotées (ZIP)"),
|
110 |
gr.File(label="Données extraites (JSON)"),
|
111 |
+
gr.File(label="Rapport généré (DOCX)")
|
112 |
],
|
113 |
title="Extraction de texte PDF et création d'un rapport DOCX",
|
114 |
description="""
|