Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -511,10 +511,14 @@ class TextClassifier:
|
|
| 511 |
}
|
| 512 |
|
| 513 |
# Function to handle file upload, OCR processing, and text analysis
|
| 514 |
-
def handle_file_upload_and_analyze(file_obj, mode: str
|
| 515 |
"""
|
| 516 |
Handle file upload, OCR processing, and text analysis
|
| 517 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 518 |
if file_obj is None:
|
| 519 |
return (
|
| 520 |
"No file uploaded",
|
|
@@ -587,7 +591,7 @@ def handle_file_upload_and_analyze(file_obj, mode: str, classifier: TextClassifi
|
|
| 587 |
|
| 588 |
# Call the original text analysis function with the extracted text
|
| 589 |
logger.info("Proceeding with text analysis")
|
| 590 |
-
return analyze_text(extracted_text, mode,
|
| 591 |
|
| 592 |
except Exception as e:
|
| 593 |
logger.error(f"Error in file upload processing: {str(e)}")
|
|
@@ -920,7 +924,7 @@ def create_interface():
|
|
| 920 |
outputs=[output_html, output_sentences, output_result]
|
| 921 |
)
|
| 922 |
|
| 923 |
-
# Use the
|
| 924 |
file_upload.change(
|
| 925 |
fn=handle_file_upload_and_analyze,
|
| 926 |
inputs=[file_upload, mode_selection],
|
|
|
|
| 511 |
}
|
| 512 |
|
| 513 |
# Function to handle file upload, OCR processing, and text analysis
|
| 514 |
+
def handle_file_upload_and_analyze(file_obj, mode: str) -> tuple:
|
| 515 |
"""
|
| 516 |
Handle file upload, OCR processing, and text analysis
|
| 517 |
"""
|
| 518 |
+
# Use the global classifier
|
| 519 |
+
global classifier
|
| 520 |
+
classifier_to_use = classifier
|
| 521 |
+
|
| 522 |
if file_obj is None:
|
| 523 |
return (
|
| 524 |
"No file uploaded",
|
|
|
|
| 591 |
|
| 592 |
# Call the original text analysis function with the extracted text
|
| 593 |
logger.info("Proceeding with text analysis")
|
| 594 |
+
return analyze_text(extracted_text, mode, classifier_to_use)
|
| 595 |
|
| 596 |
except Exception as e:
|
| 597 |
logger.error(f"Error in file upload processing: {str(e)}")
|
|
|
|
| 924 |
outputs=[output_html, output_sentences, output_result]
|
| 925 |
)
|
| 926 |
|
| 927 |
+
# Use the file upload handler without passing classifier (will use global)
|
| 928 |
file_upload.change(
|
| 929 |
fn=handle_file_upload_and_analyze,
|
| 930 |
inputs=[file_upload, mode_selection],
|