File size: 514 Bytes
21fece8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c024813
 
21fece8
5e2fc9d
21fece8
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
import numpy as np


def branin(x1, x2):
    y = float(
        (x2 - 5.1 / (4 * np.pi**2) * x1**2 + 5.0 / np.pi * x1 - 6.0) ** 2
        + 10 * (1 - 1.0 / (8 * np.pi)) * np.cos(x1)
        + 10
    )

    return y


iface = gr.Interface(
    fn=branin,
    inputs=[
        gr.Number(0.25, label="x1", minimum=-5.0, maximum=10.0),
        gr.Number(0.75, label="x2", minimum=0.0, maximum=10.0),
    ],
    outputs=gr.Number(branin(0.25, 0.75), label="branin function value"),
)
iface.launch()