EmilyWitko HF staff commited on
Commit
c7a0ce6
1 Parent(s): 461c693

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -13
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
- pets = {
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
- def show_pet_image(pet_name):
11
- # If the pet name is in the dictionary, return the image
12
- if pet_name in pets:
13
- return pets[pet_name]
14
- else:
15
- return "Pet not found, please try another name."
16
 
17
- iface = gr.Interface(
18
- fn=show_pet_image,
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()