Spaces:
Runtime error
Runtime error
Matthias Kleiner
commited on
Commit
·
455edde
1
Parent(s):
4f4eb2d
try to use the restart space if it is paused
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
import os
|
4 |
import random
|
5 |
import datetime
|
|
|
6 |
|
7 |
def check_password(username, password):
|
8 |
if password == os.environ["ACCESS"]:
|
@@ -14,6 +15,19 @@ def check_password(username, password):
|
|
14 |
def func(file, number_of_pages, secret):
|
15 |
if secret != os.environ["ACCESS"]:
|
16 |
return "Wrong password, please try again"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
output = client.predict(file, number_of_pages)
|
18 |
if "Error" in output:
|
19 |
return output
|
@@ -32,6 +46,7 @@ def func(file, number_of_pages, secret):
|
|
32 |
def upload_file(file):
|
33 |
return file.name
|
34 |
|
|
|
35 |
description = r"""
|
36 |
<h3> SCIDECK is a tool that allows you to convert your PDF files into a presentation deck.</h3>
|
37 |
<br>
|
@@ -42,9 +57,7 @@ description = r"""
|
|
42 |
3️⃣ <b>Enter the password provided in the invite email.</b><br>
|
43 |
4️⃣ <b>Click the Generate button</b>: Initiate the slide generation process by clicking the designated "Generate" button.<br>
|
44 |
5️⃣ <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 |
🖼️ Some examples of slides generated using <b>SCIDECK</b> are shown below: <br>
|
50 |
1. Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift [[Paper]](https://arxiv.org/pdf/1502.03167.pdf) [[Slides]](https://drive.google.com/file/d/1Zt5FFH0nKxut-LyEr9pNAIdtgR_lBtIj/view?usp=sharing) <br>
|
@@ -58,8 +71,8 @@ ver 0.1
|
|
58 |
read_key = os.environ.get("HF_TOKEN", None)
|
59 |
|
60 |
if __name__ == "__main__":
|
61 |
-
client = Client.duplicate("ByMatthew/deckify_private", hf_token=read_key)
|
62 |
-
|
63 |
temp = "<h1> SCIDECK: Generate slides (LaTeX Beamer) from PDF</h1>"
|
64 |
with gr.Blocks() as demo:
|
65 |
gr.Markdown(temp)
|
|
|
3 |
import os
|
4 |
import random
|
5 |
import datetime
|
6 |
+
from huggingface_hub import hf_api
|
7 |
|
8 |
def check_password(username, password):
|
9 |
if password == os.environ["ACCESS"]:
|
|
|
15 |
def func(file, number_of_pages, secret):
|
16 |
if secret != os.environ["ACCESS"]:
|
17 |
return "Wrong password, please try again"
|
18 |
+
|
19 |
+
space_runtime = hf_api.get_space_runtime("ByMatthew/deckify_private", token=read_key)
|
20 |
+
print(f"Space runtime: {space_runtime}")
|
21 |
+
|
22 |
+
if not space_runtime.status == "RUNNING": # might need to check lowercase or something
|
23 |
+
|
24 |
+
space_runtime_after_restart = hf_api.restart_space("ByMatthew/deckify_private", token=read_key)
|
25 |
+
print(f"Space runtime after restart: {space_runtime_after_restart}")
|
26 |
+
|
27 |
+
client = Client("ByMatthew/deckify_private", hf_token=read_key)
|
28 |
+
|
29 |
+
print(f"Client: {client}")
|
30 |
+
|
31 |
output = client.predict(file, number_of_pages)
|
32 |
if "Error" in output:
|
33 |
return output
|
|
|
46 |
def upload_file(file):
|
47 |
return file.name
|
48 |
|
49 |
+
# 📝 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>
|
50 |
description = r"""
|
51 |
<h3> SCIDECK is a tool that allows you to convert your PDF files into a presentation deck.</h3>
|
52 |
<br>
|
|
|
57 |
3️⃣ <b>Enter the password provided in the invite email.</b><br>
|
58 |
4️⃣ <b>Click the Generate button</b>: Initiate the slide generation process by clicking the designated "Generate" button.<br>
|
59 |
5️⃣ <b>Be patient 🙂</b>: Generating the slides could take between 1 minute and 5 minutes.<br>
|
|
|
60 |
|
|
|
61 |
|
62 |
🖼️ Some examples of slides generated using <b>SCIDECK</b> are shown below: <br>
|
63 |
1. Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shift [[Paper]](https://arxiv.org/pdf/1502.03167.pdf) [[Slides]](https://drive.google.com/file/d/1Zt5FFH0nKxut-LyEr9pNAIdtgR_lBtIj/view?usp=sharing) <br>
|
|
|
71 |
read_key = os.environ.get("HF_TOKEN", None)
|
72 |
|
73 |
if __name__ == "__main__":
|
74 |
+
# client = Client.duplicate("ByMatthew/deckify_private", hf_token=read_key)
|
75 |
+
|
76 |
temp = "<h1> SCIDECK: Generate slides (LaTeX Beamer) from PDF</h1>"
|
77 |
with gr.Blocks() as demo:
|
78 |
gr.Markdown(temp)
|