File size: 2,078 Bytes
f8ccd9c edd57c3 cab36bf edd57c3 cab36bf de8d8bf fd188ea 065b429 fd188ea 8da6c61 5054699 6b1f1f9 5054699 a6ed840 5054699 cab36bf de8d8bf cab36bf f8ccd9c cab36bf 59fb81e 8da6c61 59fb81e d9efbf0 f8ccd9c fd188ea f8ccd9c 8da6c61 cab36bf fd188ea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
from gradio_client import Client
import gradio as gr
import os
def check_password(username, password):
if password == os.environ["ACCESS"]:
return True
else:
return False
def func(file, number_of_pages, secret):
if secret != os.environ["ACCESS"]:
return "Wrong password, please try again"
else:
return client.predict(file, number_of_pages)
def upload_file(file):
return file.name
description = r"""
<b> Scideck </b> is a tool that allows you to convert your PDF files into a presentation deck.
<br>
❗️❗️❗️[<b>Important</b>] Instructions:<br>
1️⃣ <b>Upload the PDF document</b>: Select the PDF file you want to convert into slides.<br>
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>
3️⃣ <b>Click the Generate button</b>: Initiate the slide generation process by clicking the designated "Generate" button.<br>
4️⃣ <b>Wait for approximately 200 seconds</b>: Allow a brief moment for the system to generate the slides. The process may take up to 200 seconds.<br>
"""
read_key = os.environ.get("HF_TOKEN", None)
if __name__ == "__main__":
client = Client.duplicate("Nauryzbay/deckify_private", hf_token=read_key)
with gr.Blocks() as demo:
gr.Markdown("# Scideck: Generate slides (LaTeX Beamer) from PDF")
gr.Markdown(description)
file_output = gr.File()
upload_button = gr.UploadButton("Click to Upload a PDF File", file_types=["file"], file_count="single", size="sm")
upload_button.upload(upload_file, upload_button, file_output)
number_of_pages = gr.Number(label="Number of pages")
secret = gr.Textbox(label="Password", type="password")
output = gr.Textbox(label="Output")
greet_btn = gr.Button("Generate slides")
greet_btn.click(fn=func, inputs=[upload_button, number_of_pages, secret], outputs=output, api_name="greet")
demo.queue(max_size=5)
demo.launch() |