import gradio as gr import subprocess def fun(filepath): print(f"filepath is - {filepath}") # Command to run bash_command = f"nougat {filepath}" # Run the command and capture its output completed_process = subprocess.run(bash_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) # Get the output and error messages output = completed_process.stdout errors = completed_process.stderr # Print the output and errors 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(' OR ', 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)