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()