remove latex tags
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from gradio_client import Client
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
|
|
|
| 4 |
|
| 5 |
def check_password(username, password):
|
| 6 |
if password == os.environ["ACCESS"]:
|
|
@@ -8,11 +9,25 @@ def check_password(username, password):
|
|
| 8 |
else:
|
| 9 |
return False
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def func(file, number_of_pages, secret):
|
| 12 |
if secret != os.environ["ACCESS"]:
|
| 13 |
return "Wrong password, please try again"
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
def upload_file(file):
|
| 18 |
return file.name
|
|
@@ -24,9 +39,11 @@ description = r"""
|
|
| 24 |
❗️❗️❗️[<b>Important</b>] Instructions:<br>
|
| 25 |
1️⃣ <b>Upload the PDF document</b>: Select the PDF file you want to convert into slides.<br>
|
| 26 |
2️⃣ <b>Specify the number of pages</b>: Indicate the range of pages you'd like to include in the slide generation. <b>Set it to 0</b> if you want to include all pages. <br>
|
|
|
|
| 27 |
3️⃣ <b>Click the Generate button</b>: Initiate the slide generation process by clicking the designated "Generate" button.<br>
|
| 28 |
-
4️⃣ <b>
|
| 29 |
|
|
|
|
| 30 |
📝 If you get an error message, you can send me email with the PDF file attached to this email address: <b>nkoisheke [at] ethz [dot] ch</b>, and I will generate the slides for you. If there are any other issues or questions, please do not hesitate to contact me 🤗 <br>
|
| 31 |
"""
|
| 32 |
|
|
|
|
| 1 |
from gradio_client import Client
|
| 2 |
import gradio as gr
|
| 3 |
import os
|
| 4 |
+
import random
|
| 5 |
|
| 6 |
def check_password(username, password):
|
| 7 |
if password == os.environ["ACCESS"]:
|
|
|
|
| 9 |
else:
|
| 10 |
return False
|
| 11 |
|
| 12 |
+
def remove_latex_tags(input_string):
|
| 13 |
+
if input_string.startswith("```latex") and input_string.endswith("```"):
|
| 14 |
+
# Remove the ```latex at the beginning and ``` at the end
|
| 15 |
+
result_string = input_string[len("```latex"):-len("```")]
|
| 16 |
+
return result_string
|
| 17 |
+
else:
|
| 18 |
+
# If the input string doesn't have the expected tags, return it unchanged
|
| 19 |
+
return input_string
|
| 20 |
+
|
| 21 |
def func(file, number_of_pages, secret):
|
| 22 |
if secret != os.environ["ACCESS"]:
|
| 23 |
return "Wrong password, please try again"
|
| 24 |
+
text = client.predict(file, number_of_pages)
|
| 25 |
+
text = remove_latex_tags(text)
|
| 26 |
+
# generate a random sequence of numbers
|
| 27 |
+
# s = "".join([str(random.randint(0, 9)) for i in range(10)])
|
| 28 |
+
# with open(f"{s}.tex", "w", encoding="utf-8") as f:
|
| 29 |
+
# f.write(text)
|
| 30 |
+
return text
|
| 31 |
|
| 32 |
def upload_file(file):
|
| 33 |
return file.name
|
|
|
|
| 39 |
❗️❗️❗️[<b>Important</b>] Instructions:<br>
|
| 40 |
1️⃣ <b>Upload the PDF document</b>: Select the PDF file you want to convert into slides.<br>
|
| 41 |
2️⃣ <b>Specify the number of pages</b>: Indicate the range of pages you'd like to include in the slide generation. <b>Set it to 0</b> if you want to include all pages. <br>
|
| 42 |
+
3️⃣ <b>Enter the password provided in the invite email.</b>
|
| 43 |
3️⃣ <b>Click the Generate button</b>: Initiate the slide generation process by clicking the designated "Generate" button.<br>
|
| 44 |
+
4️⃣ <b>Be patient 🙂</b>: Generating the slides could take between 1 minute and 5 minutes.<br>
|
| 45 |
|
| 46 |
+
|
| 47 |
📝 If you get an error message, you can send me email with the PDF file attached to this email address: <b>nkoisheke [at] ethz [dot] ch</b>, and I will generate the slides for you. If there are any other issues or questions, please do not hesitate to contact me 🤗 <br>
|
| 48 |
"""
|
| 49 |
|