Sivainti commited on
Commit
3683210
·
verified ·
1 Parent(s): c7225f5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load translation pipeline (English to French as example)
5
+ translator = pipeline("translation_en_to_fr")
6
+
7
+ # Function that takes name and image
8
+ def greet_translate_and_show(name, image):
9
+ greeting = f"Hello, {name}!" if name else "Hello!"
10
+
11
+ # Translate the greeting
12
+ translation = translator(greeting)[0]['translation_text']
13
+
14
+ return greeting, translation, image
15
+
16
+ # Interface with text and image inputs, and 3 outputs
17
+ iface = gr.Interface(
18
+ fn=greet_translate_and_show,
19
+ inputs=[
20
+ gr.Text(label="Your Name"),
21
+ gr.Image(type="pil", label="Upload an Image")
22
+ ],
23
+ outputs=[
24
+ gr.Text(label="Greeting in English"),
25
+ gr.Text(label="Translated Greeting (French)"),
26
+ gr.Image(label="Your Image")
27
+ ]
28
+ )
29
+
30
+ iface.launch()