Spaces:
Runtime error
Runtime error
Commit
•
f3f10d4
1
Parent(s):
807dd72
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,36 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
"David": "./
|
6 |
-
"Kikou": "./
|
7 |
-
# Add
|
8 |
}
|
9 |
|
10 |
-
# Define your
|
11 |
-
def your_function(pet_name):
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
return image_path
|
15 |
|
16 |
# Create the interface
|
17 |
-
|
18 |
|
19 |
# Launch the interface
|
20 |
-
|
21 |
|
22 |
if __name__ == "__main__":
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Define the nested dictionary of owners and their respective pets
|
4 |
+
owner_pets = {
|
5 |
+
"Emily": {"David": "./David.jpg"},
|
6 |
+
"Sasha": {"Kikou": "./Kikou.jpg"},
|
7 |
+
# Add more owners and their pets as needed
|
8 |
}
|
9 |
|
10 |
+
# Define your function
|
11 |
+
def your_function(owner_name, pet_name):
|
12 |
+
pets = owner_pets.get(owner_name)
|
13 |
+
|
14 |
+
pet_image = None
|
15 |
+
if pets and pet_name in pets:
|
16 |
+
pet_image = pets[pet_name]
|
17 |
+
|
18 |
+
return pet_image or "./download.jpeg"
|
19 |
+
|
20 |
+
# Define your Gradio interface
|
21 |
+
def your_gradio_function(owner_name, pet_name):
|
22 |
+
image_path = your_function(owner_name, pet_name)
|
23 |
return image_path
|
24 |
|
25 |
# Create the interface
|
26 |
+
interface = gr.Interface(fn=your_gradio_function, inputs=["text", "text"], outputs="image")
|
27 |
|
28 |
# Launch the interface
|
29 |
+
interface.launch()
|
30 |
|
31 |
if __name__ == "__main__":
|
32 |
+
interface.inputs([{"label": "Owner Name", "type": "text"}, {"label": "Pet Name", "type": "text"}])
|
33 |
+
interface.input("Owner Name").send_value("John Doe")
|
34 |
+
interface.input("Pet Name").send_value("Doggo")
|
35 |
+
output = interface.run().result()
|
36 |
+
print(f"Image for Emily and David: {output}")
|