0

I have successfully implemented a button in Gardio that runs a script.

def generate_output(input_path,output_path):
    cmd = f"python parse.py \"{input_path}\" \"{output_path}\""
    subprocess.call(cmd, shell=True)

with gr.Row():
                    btn_run = gr.Button(
                        'RUN', elem_id='generate'
                    )
                    btn_run.click(
                        fn=generate_output,
                        inputs =[tb_input_path,tb_output_path],
                        outputs=[]
                    )

Although the script actually runs when the button is pressed, there is no intuitive UI that informs the user of what is happening, making it difficult to know what is going on.

I want a UI that can inform the execution rate. For example, like this.

text_informs = gr.Markdown("")
def generate_output(input_path,output_path):
    text_informs.update("started!")
    try:
        cmd = f"python parse.py \"{input_path}\" \"{output_path}\""
        subprocess.call(cmd, shell=True)
        text_informs.update("Completed")
    except subprocess.CalledProcessError as e:
        text_informs.update("error occured!")

How can the execution rate be informed? If something can be informed that the script is running, any means will be okay.

sooyeon
  • 488
  • 1
  • 5
  • 16

1 Answers1

0

If you're asking for something like a progress bar you can use either tqdm or rich module

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – xlmaster Feb 21 '23 at 08:32