Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,19 +2,19 @@ import gradio as gr
|
|
| 2 |
|
| 3 |
# Function to convert kilometers to meters or centimeters
|
| 4 |
def convert_distance(km, scale):
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
# Gradio interface
|
| 11 |
iface = gr.Interface(
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
)
|
| 19 |
|
| 20 |
# Launch the interface
|
|
|
|
| 2 |
|
| 3 |
# Function to convert kilometers to meters or centimeters
|
| 4 |
def convert_distance(km, scale):
|
| 5 |
+
if scale == "Meters":
|
| 6 |
+
return km * 1000 # Convert to meters
|
| 7 |
+
elif scale == "Centimeters":
|
| 8 |
+
return km * 100000 # Convert to centimeters
|
| 9 |
|
| 10 |
# Gradio interface
|
| 11 |
iface = gr.Interface(
|
| 12 |
+
fn=convert_distance,
|
| 13 |
+
inputs=[
|
| 14 |
+
gr.Number(label="Distance in Kilometers"), # Input field for kilometers
|
| 15 |
+
gr.Radio(["Meters", "Centimeters"], label="Select Unit") # Radio button for unit selection
|
| 16 |
+
],
|
| 17 |
+
outputs=gr.Number(label="Converted Distance") # Output field for the converted distance
|
| 18 |
)
|
| 19 |
|
| 20 |
# Launch the interface
|