|
import gradio as gr |
|
import subprocess |
|
|
|
def fun(filepath): |
|
print(f"filepath is - {filepath}") |
|
|
|
bash_command = f"nougat {filepath}" |
|
|
|
|
|
completed_process = subprocess.run(bash_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) |
|
|
|
|
|
output = completed_process.stdout |
|
errors = completed_process.stderr |
|
|
|
|
|
print("Output:") |
|
print(len(output)) |
|
|
|
print("Errors:") |
|
print(len(errors)) |
|
return output |
|
|
|
with gr.Blocks() as demo: |
|
|
|
with gr.Row(): |
|
pdf_file = gr.File(label='Upload a PDF', scale=1) |
|
mkd = gr.HTML(' <i>OR</i> ', scale=1) |
|
pdf_link = gr.Textbox(placeholder='Enter an arxiv link here', label='Provide a link', scale=1) |
|
|
|
with gr.Row(): |
|
btn = gr.Button() |
|
parsed_output = gr.Textbox(lines=5) |
|
|
|
btn.click(fun, pdf_file, parsed_output) |
|
|
|
demo.launch(debug=True) |
|
|