File size: 427 Bytes
b31d1c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import gradio as gr
import re

def fetch_numbers(text):
    numbers=re.findall(r'-?\d+\.?\d*', text)
    return [float(num) for num in numbers]

inputs=gr.Textbox(label='從文本中擷取數字',
                  lines=7,
                  placeholder='輸入文數字')
demo=gr.Interface(fn=fetch_numbers, 
                  inputs=inputs, 
                  outputs="textbox")

if __name__ == "__main__":
    demo.launch()