File size: 1,425 Bytes
f7d3e7a
2bbd7ff
f7d3e7a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1fb4d5d
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
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from transformers import pipeline

## height = meter  weight in kg
def bmi(name, height, weight, Gender):
    try:
        bmi_val = weight * 10000 / (height ** 2)
        bmi_str = 'name : ' + name + '\n' +   'Your BMI is ' + str(bmi_val)
        sex = 'Male' if Gender else 'Female'
    except:
        print("An exception occurred")
        bmi_str = 'Error in value '
        sex = 'Male' if Gender else 'Female'
    return (bmi_str, sex)

# print(bmi('david', 1.52, 64))

interface = gr.Interface(fn=bmi,
                         inputs=["text",
                                gr.inputs.Slider(0,500, label="Height in CM"),
                                gr.inputs.Slider(0,100, label="Weight in KG"),
                                gr.inputs.Checkbox(label="Gender (Default Male)")
                                ],
                         outputs=["text", "text"],
                         examples = [['david', 155, 64, True],
                                     ['nelly', 155, 55, False]],
                         live=False,
                         flagging_options = ["yes", "no", "Maybe"],
                         theme='dark-peach',
                         # css ="""
                         # body {background-color:yellow}
                         # """,
                         description = "Flag if you find any error"
                         )
interface.launch(share=True)