Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
# Assuming you have a dictionary of pet names and their image URLs or file paths
|
| 4 |
-
|
| 5 |
"David": "Users/EmilyWitko/desktop/David AI/david.jpg",
|
| 6 |
"Kikou": "Users/EmilyWitko/desktop/David AI/kikou.jpg",
|
| 7 |
# Add as many pets as you have
|
| 8 |
}
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
return "Pet not found, please try another name."
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
inputs=gr.inputs.Textbox(label="Enter Pet Name"),
|
| 20 |
-
outputs=gr.outputs.Image(label="Pet Image"),
|
| 21 |
-
examples=list(pets.keys()) # Optional: to provide example pet names in the interface
|
| 22 |
-
)
|
| 23 |
|
|
|
|
| 24 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
# Assuming you have a dictionary of pet names and their image URLs or file paths
|
| 4 |
+
pet_images = {
|
| 5 |
"David": "Users/EmilyWitko/desktop/David AI/david.jpg",
|
| 6 |
"Kikou": "Users/EmilyWitko/desktop/David AI/kikou.jpg",
|
| 7 |
# Add as many pets as you have
|
| 8 |
}
|
| 9 |
|
| 10 |
+
# Define your Gradio interface here
|
| 11 |
+
def your_function(pet_name):
|
| 12 |
+
# Handle the input and produce the image path or URL
|
| 13 |
+
image_path = pet_images.get(pet_name, "Users/EmilyWitko/desktop/David AI/david.jpg") # Default if pet not found
|
| 14 |
+
return image_path
|
|
|
|
| 15 |
|
| 16 |
+
# Create the interface
|
| 17 |
+
iface = gr.Interface(fn=your_function, inputs="text", outputs="image")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# Launch the interface
|
| 20 |
iface.launch()
|