BergarBro's picture
modified
c0de41e
Raw History Blame Contribute Delete
766 Bytes
import gradio as gr
import spaces
operations = ["Addition","Subtraction","Multiplication","Division"]
@spaces.GPU
def calculation(a,op,b):
if op == operations[0] :
return a + b
if op == operations[1] :
return a - b
if op == operations[2] :
return a * b
if op == operations[3] :
return a / b
with gr.Blocks() as demo :
gr.Markdown("My First App")
num1 = gr.Number(label="First Number")
num2 = gr.Number(label="Second Number")
op = gr.Dropdown(choices=operations,label="Typ of Operation")
add_button = gr.Button("Add")
output = gr.Number(label="Reslut")
add_button.click(
fn=calculation,
inputs=[num1,op,num2],
outputs=output
)
demo.launch()