Spaces:
Runtime error
Runtime error
Commit
•
c91ff76
1
Parent(s):
e787464
Update app.py
Browse files
app.py
CHANGED
@@ -22,6 +22,17 @@ def clean_text(text):
|
|
22 |
text = re.sub(r'\s+', ' ', text)
|
23 |
return text.strip()
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
def image_to_latex(image):
|
26 |
image_path = "/tmp/equation.png" # Modify as needed
|
27 |
image.save(image_path)
|
@@ -62,8 +73,7 @@ def pdf_to_text(file):
|
|
62 |
|
63 |
return output_file_name
|
64 |
|
65 |
-
|
66 |
-
iface = gr.Interface(fn=pdf_to_text,
|
67 |
inputs=gr.inputs.File(label="Your PDF"),
|
68 |
outputs=gr.outputs.File(label="Download TXT"),
|
69 |
title="PDF to TXT",
|
|
|
22 |
text = re.sub(r'\s+', ' ', text)
|
23 |
return text.strip()
|
24 |
|
25 |
+
def safe_base64_decode(s):
|
26 |
+
# add missing padding if necessary
|
27 |
+
missing_padding = len(s) % 4
|
28 |
+
if missing_padding:
|
29 |
+
s += '='* (4 - missing_padding)
|
30 |
+
try:
|
31 |
+
return base64.b64decode(s)
|
32 |
+
except binascii.Error as e:
|
33 |
+
print("Error decoding base64 string:", e)
|
34 |
+
return None
|
35 |
+
|
36 |
def image_to_latex(image):
|
37 |
image_path = "/tmp/equation.png" # Modify as needed
|
38 |
image.save(image_path)
|
|
|
73 |
|
74 |
return output_file_name
|
75 |
|
76 |
+
iface = grInterface(fn=pdf_to_text,
|
|
|
77 |
inputs=gr.inputs.File(label="Your PDF"),
|
78 |
outputs=gr.outputs.File(label="Download TXT"),
|
79 |
title="PDF to TXT",
|