Spaces:
Runtime error
Runtime error
import gradio as gr | |
# Define the nested dictionary of owners and their respective pets | |
owner_pets = { | |
"Emily": {"David": "./David.jpg"}, | |
"Sasha": {"Kikou": "./Kikou.jpg"}, | |
# Add more owners and their pets as needed | |
} | |
# Define your function | |
def your_function(owner_name, pet_name): | |
pets = owner_pets.get(owner_name) | |
pet_image = None | |
if pets and pet_name in pets: | |
pet_image = pets[pet_name] | |
return pet_image or "./download.jpeg" | |
# Define your Gradio interface | |
def your_gradio_function(owner_name, pet_name): | |
image_path = your_function(owner_name, pet_name) | |
return image_path | |
# Create the interface | |
interface = gr.Interface(fn=your_gradio_function, inputs=["text", "text"], outputs="image") | |
# Launch the interface | |
interface.launch() | |
if __name__ == "__main__": | |
interface.inputs([{"label": "Owner Name", "type": "text"}, {"label": "Pet Name", "type": "text"}]) | |
interface.input("Owner Name").send_value("John Doe") | |
interface.input("Pet Name").send_value("Doggo") | |
output = interface.run().result() | |
print(f"Image for Emily and David: {output}") |