Spaces:
Runtime error
Runtime error
Download app.py from davidcftang/LT: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/davidcftang/LT/resolve/main/app.py
- Command line
-
hf download hf://spaces/davidcftang/LT/app.py
-
curl -L -o app.py https://huggingface.co/spaces/davidcftang/LT/resolve/main/app.py
1.43 kB
| 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) | |