Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
import re
|
| 6 |
-
from PyPDF2 import PdfReader
|
| 7 |
from collections import defaultdict
|
| 8 |
from typing import Dict, List, Optional, Tuple, Union
|
| 9 |
import html
|
|
@@ -16,10 +16,6 @@ MAX_FILE_SIZE_MB = 5
|
|
| 16 |
MIN_AGE = 5
|
| 17 |
MAX_AGE = 120
|
| 18 |
|
| 19 |
-
# ========== NER MODEL HANDLING (DISABLED FOR HF SPACES) ==========
|
| 20 |
-
# Disabled for Hugging Face Spaces compatibility
|
| 21 |
-
ner_pipeline = None
|
| 22 |
-
|
| 23 |
# ========== UTILITY FUNCTIONS ==========
|
| 24 |
def sanitize_input(text: str) -> str:
|
| 25 |
"""Sanitize user input to prevent XSS and injection attacks."""
|
|
@@ -129,8 +125,6 @@ def parse_transcript(file_obj) -> Tuple[str, Optional[Dict]]:
|
|
| 129 |
page_text = page.extract_text()
|
| 130 |
if page_text:
|
| 131 |
text += page_text + '\n'
|
| 132 |
-
except PdfReadError:
|
| 133 |
-
raise gr.Error("Failed to read PDF file - may be corrupted")
|
| 134 |
except Exception as e:
|
| 135 |
raise gr.Error(f"Error processing PDF: {str(e)}")
|
| 136 |
|
|
@@ -980,10 +974,10 @@ def create_interface():
|
|
| 980 |
|
| 981 |
return app
|
| 982 |
|
| 983 |
-
# Create
|
| 984 |
app = create_interface()
|
| 985 |
|
| 986 |
-
# For Hugging Face Spaces
|
| 987 |
if __name__ == "__main__":
|
| 988 |
app.launch()
|
| 989 |
|
|
|
|
| 3 |
import json
|
| 4 |
import os
|
| 5 |
import re
|
| 6 |
+
from PyPDF2 import PdfReader
|
| 7 |
from collections import defaultdict
|
| 8 |
from typing import Dict, List, Optional, Tuple, Union
|
| 9 |
import html
|
|
|
|
| 16 |
MIN_AGE = 5
|
| 17 |
MAX_AGE = 120
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# ========== UTILITY FUNCTIONS ==========
|
| 20 |
def sanitize_input(text: str) -> str:
|
| 21 |
"""Sanitize user input to prevent XSS and injection attacks."""
|
|
|
|
| 125 |
page_text = page.extract_text()
|
| 126 |
if page_text:
|
| 127 |
text += page_text + '\n'
|
|
|
|
|
|
|
| 128 |
except Exception as e:
|
| 129 |
raise gr.Error(f"Error processing PDF: {str(e)}")
|
| 130 |
|
|
|
|
| 974 |
|
| 975 |
return app
|
| 976 |
|
| 977 |
+
# Create the interface
|
| 978 |
app = create_interface()
|
| 979 |
|
| 980 |
+
# For Hugging Face Spaces deployment
|
| 981 |
if __name__ == "__main__":
|
| 982 |
app.launch()
|
| 983 |
|