输出控件显示进度,进度结束显示控件结果
import gradio as gr
import timedef slowly_reverse(word, progress=gr.Progress()):progress(0, desc="Starting")time.sleep(1)progress(0.05)new_string = ""for letter in progress.tqdm(word, desc="Reversing"):time.sleep(0.25)new_string = letter + new_stringreturn new_stringdemo = gr.Interface(slowly_reverse, gr.Text(), [gr.Text(),gr.Textbox()])demo.launch()
count = 0
progress = gr.Progress()
progress(0, desc="Starting")
while True:if count != 10:progress(count / 10)count = count + 1else:break