Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load translation pipeline (English to French as example) | |
| translator = pipeline("translation_en_to_fr") | |
| # Function that takes name and image | |
| def greet_translate_and_show(name, image): | |
| greeting = f"Hello, {name}!" if name else "Hello!" | |
| # Translate the greeting | |
| translation = translator(greeting)[0]['translation_text'] | |
| return greeting, translation, image | |
| # Interface with text and image inputs, and 3 outputs | |
| iface = gr.Interface( | |
| fn=greet_translate_and_show, | |
| inputs=[ | |
| gr.Text(label="Your Name"), | |
| gr.Image(type="pil", label="Upload an Image") | |
| ], | |
| outputs=[ | |
| gr.Text(label="Greeting in English"), | |
| gr.Text(label="Translated Greeting (French)"), | |
| gr.Image(label="Your Image") | |
| ] | |
| ) | |
| iface.launch() |