Peeble commited on
Commit
3574d28
·
verified ·
1 Parent(s): c2683bf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load GPT-2 model from Hugging Face
5
+ generator = pipeline("text-generation", model="gpt2")
6
+
7
+ def text_to_emoji(text):
8
+ prompt = f"Convert this sentence to emojis: {text} ->"
9
+
10
+ # Generate emoji output
11
+ result = generator(prompt, max_length=50, num_return_sequences=1)
12
+
13
+ emoji_output = result[0]['generated_text'].split("->")[-1].strip()
14
+ return emoji_output
15
+
16
+ # Gradio Interface
17
+ iface = gr.Interface(fn=text_to_emoji,
18
+ inputs=gr.Textbox(label="Enter Text"),
19
+ outputs=gr.Textbox(label="Emoji Output"),
20
+ title="Text-to-Emoji AI",
21
+ description="Enter a sentence and get the emoji equivalent!")
22
+
23
+ iface.launch()