Spaces:
Sleeping
Sleeping
File size: 565 Bytes
1388cc0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
# Function to convert kilometers to meters or centimeters
def convert_distance(km, scale):
if scale == "Meters":
return km * 1000 # Convert to meters
elif scale == "Centimeters":
return km * 100000 # Convert to centimeters
# Gradio interface
iface = gr.Interface(
fn=convert_distance,
inputs=[
gr.Number(label="Distance in Kilometers"),
gr.Radio(["Meters", "Centimeters"], label="Select Unit")
],
outputs=gr.Number(label="Converted Distance")
)
# Launch the interface
iface.launch() |