File size: 1,007 Bytes
6cd0213
ba4cfbf
6cd0213
ba4cfbf
 
 
 
 
 
 
 
bfbe667
ba4cfbf
6cd0213
ba4cfbf
bfbe667
ba4cfbf
 
 
 
 
 
 
bfbe667
ba4cfbf
bfbe667
 
ba4cfbf
bfbe667
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
import gradio as gr
import json

# Function to collect inputs and return a JSON
def create_json(sex, age, weight, height, diet):
    data = {
        "sex": sex,
        "age": age,
        "weight": weight,
        "height": height,
        "dietary preference": diet,
    }
    return json.dumps(data, indent=4)  # Convert the dictionary to a JSON string with indentation

# Create Gradio UI with input components for sex, age, weight, height, and diet
iface = gr.Interface(
    create_json,
    [
        gr.components.Radio(["Male", "Female", "Other"], label="Sex"),
        gr.components.Slider(minimum=0, maximum=120, default=25, label="Age"),
        gr.components.Slider(minimum=0, maximum=200, default=65, label="Weight (kg)"),
        gr.components.Slider(minimum=0, maximum=250, default=170, label="Height (cm)"),
        gr.components.Dropdown(["Veg", "Non-Veg", "Vegan"], label="Dietary Preference"),
    ],
    gr.components.JSON(label="Output JSON")
)

# Launch the Gradio app
iface.launch()