Spaces:
Runtime error
Runtime error
File size: 636 Bytes
a53e317 fa5f2f6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import numpy as np
import gradio as gr
def mycalculator(in_num_a,in_num_b,method):
if method == "add":
return in_num_a + in_num_b
if method == "minus":
return in_num_a - in_num_b
if method == "multiply":
return in_num_a * in_num_b
if method == "divide":
if in_num_b!=0.0:
return in_num_a/in_num_b
else:
return np.nan
demo = gr.Interface(
fn=mycalculator,
inputs=[
gr.Number(precision=5,label="a"),
gr.Number(precision=5,label="b"),
gr.Radio(["add","minus","multiply","divide"])
],
outputs="number")
demo.launch() |