Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -631,7 +631,7 @@ def launch_interface():
|
|
| 631 |
def process_pages(file, extraction_mode, start_page, end_page):
|
| 632 |
if not file:
|
| 633 |
# Return None for each output component
|
| 634 |
-
return [None
|
| 635 |
|
| 636 |
try:
|
| 637 |
if hasattr(file, 'name'):
|
|
@@ -687,7 +687,7 @@ def launch_interface():
|
|
| 687 |
page_report_file = f"{sanitized_file_name}_SDG-Page_report.docx"
|
| 688 |
primary_page_jpeg = f"{sanitized_file_name}_SDG-Page_primary_graph.jpeg"
|
| 689 |
|
| 690 |
-
|
| 691 |
page_report_file_secondary = f"{sanitized_file_name}_SDG-Page_report.docx"
|
| 692 |
secondary_page_jpeg = f"{sanitized_file_name}_SDG-Page_secondary_graph.jpeg"
|
| 693 |
|
|
@@ -708,21 +708,21 @@ def launch_interface():
|
|
| 708 |
page_csv_file,
|
| 709 |
page_report_file,
|
| 710 |
primary_page_jpeg,
|
| 711 |
-
|
| 712 |
page_report_file_secondary,
|
| 713 |
secondary_page_jpeg
|
| 714 |
)
|
| 715 |
|
| 716 |
except Exception as e:
|
| 717 |
print(f"Error: {e}")
|
| 718 |
-
return [None
|
| 719 |
|
| 720 |
# Function to process sentence-level analysis
|
| 721 |
@spaces.GPU
|
| 722 |
def process_sentences(file, extraction_mode, start_page, end_page):
|
| 723 |
if not file:
|
| 724 |
# Return None for each output component
|
| 725 |
-
return [None
|
| 726 |
|
| 727 |
try:
|
| 728 |
if hasattr(file, 'name'):
|
|
@@ -778,7 +778,7 @@ def launch_interface():
|
|
| 778 |
sentence_report_file = f"{sanitized_file_name}_SDG-Sentence_report.docx"
|
| 779 |
primary_sentence_jpeg = f"{sanitized_file_name}_SDG-Sentence_primary_graph.jpeg"
|
| 780 |
|
| 781 |
-
|
| 782 |
sentence_report_file_secondary = f"{sanitized_file_name}_SDG-Sentence_report.docx"
|
| 783 |
secondary_sentence_jpeg = f"{sanitized_file_name}_SDG-Sentence_secondary_graph.jpeg"
|
| 784 |
|
|
@@ -799,14 +799,14 @@ def launch_interface():
|
|
| 799 |
sentence_csv_file,
|
| 800 |
sentence_report_file,
|
| 801 |
primary_sentence_jpeg,
|
| 802 |
-
|
| 803 |
sentence_report_file_secondary,
|
| 804 |
secondary_sentence_jpeg
|
| 805 |
)
|
| 806 |
|
| 807 |
except Exception as e:
|
| 808 |
print(f"Error: {e}")
|
| 809 |
-
return [None
|
| 810 |
|
| 811 |
# Reset functions to clear the outputs
|
| 812 |
def reset_page_outputs():
|
|
@@ -825,7 +825,7 @@ def launch_interface():
|
|
| 825 |
page_csv, # π Download Page Predictions CSV
|
| 826 |
page_docx, # π Download Page Report DOCX
|
| 827 |
page_jpeg1, # πΌοΈ Download Primary SDGs JPEG
|
| 828 |
-
|
| 829 |
page_report_file_secondary, # π Download Page Report DOCX
|
| 830 |
secondary_page_jpeg # πΌοΈ Download Secondary SDGs JPEG
|
| 831 |
]
|
|
@@ -839,7 +839,7 @@ def launch_interface():
|
|
| 839 |
page_csv,
|
| 840 |
page_docx,
|
| 841 |
page_jpeg1,
|
| 842 |
-
|
| 843 |
page_report_file_secondary,
|
| 844 |
secondary_page_jpeg
|
| 845 |
]
|
|
@@ -855,7 +855,7 @@ def launch_interface():
|
|
| 855 |
sentence_csv, # π Download Sentence Predictions CSV
|
| 856 |
sentence_docx, # π Download Sentence Report DOCX
|
| 857 |
sentence_jpeg1, # πΌοΈ Download Primary SDGs JPEG
|
| 858 |
-
|
| 859 |
sentence_report_file_secondary, # π Download Sentence Report DOCX
|
| 860 |
secondary_sentence_jpeg # πΌοΈ Download Secondary SDGs JPEG
|
| 861 |
]
|
|
@@ -869,7 +869,7 @@ def launch_interface():
|
|
| 869 |
sentence_csv,
|
| 870 |
sentence_docx,
|
| 871 |
sentence_jpeg1,
|
| 872 |
-
|
| 873 |
sentence_report_file_secondary,
|
| 874 |
secondary_sentence_jpeg
|
| 875 |
]
|
|
|
|
| 631 |
def process_pages(file, extraction_mode, start_page, end_page):
|
| 632 |
if not file:
|
| 633 |
# Return None for each output component
|
| 634 |
+
return [None] * 8
|
| 635 |
|
| 636 |
try:
|
| 637 |
if hasattr(file, 'name'):
|
|
|
|
| 687 |
page_report_file = f"{sanitized_file_name}_SDG-Page_report.docx"
|
| 688 |
primary_page_jpeg = f"{sanitized_file_name}_SDG-Page_primary_graph.jpeg"
|
| 689 |
|
| 690 |
+
page_csv_secondary = f"{sanitized_file_name}_SDG-Page_predictions.csv"
|
| 691 |
page_report_file_secondary = f"{sanitized_file_name}_SDG-Page_report.docx"
|
| 692 |
secondary_page_jpeg = f"{sanitized_file_name}_SDG-Page_secondary_graph.jpeg"
|
| 693 |
|
|
|
|
| 708 |
page_csv_file,
|
| 709 |
page_report_file,
|
| 710 |
primary_page_jpeg,
|
| 711 |
+
page_csv_secondary,
|
| 712 |
page_report_file_secondary,
|
| 713 |
secondary_page_jpeg
|
| 714 |
)
|
| 715 |
|
| 716 |
except Exception as e:
|
| 717 |
print(f"Error: {e}")
|
| 718 |
+
return [None] * 8
|
| 719 |
|
| 720 |
# Function to process sentence-level analysis
|
| 721 |
@spaces.GPU
|
| 722 |
def process_sentences(file, extraction_mode, start_page, end_page):
|
| 723 |
if not file:
|
| 724 |
# Return None for each output component
|
| 725 |
+
return [None] * 8
|
| 726 |
|
| 727 |
try:
|
| 728 |
if hasattr(file, 'name'):
|
|
|
|
| 778 |
sentence_report_file = f"{sanitized_file_name}_SDG-Sentence_report.docx"
|
| 779 |
primary_sentence_jpeg = f"{sanitized_file_name}_SDG-Sentence_primary_graph.jpeg"
|
| 780 |
|
| 781 |
+
sentence_csv_secondary = f"{sanitized_file_name}_SDG-Sentence_predictions.csv"
|
| 782 |
sentence_report_file_secondary = f"{sanitized_file_name}_SDG-Sentence_report.docx"
|
| 783 |
secondary_sentence_jpeg = f"{sanitized_file_name}_SDG-Sentence_secondary_graph.jpeg"
|
| 784 |
|
|
|
|
| 799 |
sentence_csv_file,
|
| 800 |
sentence_report_file,
|
| 801 |
primary_sentence_jpeg,
|
| 802 |
+
sentence_csv_secondary,
|
| 803 |
sentence_report_file_secondary,
|
| 804 |
secondary_sentence_jpeg
|
| 805 |
)
|
| 806 |
|
| 807 |
except Exception as e:
|
| 808 |
print(f"Error: {e}")
|
| 809 |
+
return [None] * 8
|
| 810 |
|
| 811 |
# Reset functions to clear the outputs
|
| 812 |
def reset_page_outputs():
|
|
|
|
| 825 |
page_csv, # π Download Page Predictions CSV
|
| 826 |
page_docx, # π Download Page Report DOCX
|
| 827 |
page_jpeg1, # πΌοΈ Download Primary SDGs JPEG
|
| 828 |
+
page_csv_secondary, # π Download Page Predictions CSV
|
| 829 |
page_report_file_secondary, # π Download Page Report DOCX
|
| 830 |
secondary_page_jpeg # πΌοΈ Download Secondary SDGs JPEG
|
| 831 |
]
|
|
|
|
| 839 |
page_csv,
|
| 840 |
page_docx,
|
| 841 |
page_jpeg1,
|
| 842 |
+
page_csv_secondary,
|
| 843 |
page_report_file_secondary,
|
| 844 |
secondary_page_jpeg
|
| 845 |
]
|
|
|
|
| 855 |
sentence_csv, # π Download Sentence Predictions CSV
|
| 856 |
sentence_docx, # π Download Sentence Report DOCX
|
| 857 |
sentence_jpeg1, # πΌοΈ Download Primary SDGs JPEG
|
| 858 |
+
sentence_csv_secondary, # π Download Sentence Predictions CSV
|
| 859 |
sentence_report_file_secondary, # π Download Sentence Report DOCX
|
| 860 |
secondary_sentence_jpeg # πΌοΈ Download Secondary SDGs JPEG
|
| 861 |
]
|
|
|
|
| 869 |
sentence_csv,
|
| 870 |
sentence_docx,
|
| 871 |
sentence_jpeg1,
|
| 872 |
+
sentence_csv_secondary,
|
| 873 |
sentence_report_file_secondary,
|
| 874 |
secondary_sentence_jpeg
|
| 875 |
]
|