Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Models
|
4 |
+
jacobe = gr.Interface.load(f"huggingface/huggingtweets/jacobe")
|
5 |
+
baguioni = gr.Interface.load(f"huggingface/huggingtweets/baguioni")
|
6 |
+
elonmusk = gr.Interface.load(f"huggingface/huggingtweets/elonmusk")
|
7 |
+
realdonaldtrump = gr.Interface.load(f"huggingface/huggingtweets/realdonaldtrump")
|
8 |
+
barackobama = gr.Interface.load(f"huggingface/huggingtweets/barackobama")
|
9 |
+
karpathy = gr.Interface.load(f"huggingface/huggingtweets/karpathy")
|
10 |
+
|
11 |
+
def generated_tweet(inputtext, user):
|
12 |
+
if user == 'jacobe':
|
13 |
+
tweet = jacobe(inputtext)
|
14 |
+
if user == 'baguioni':
|
15 |
+
tweet = baguioni(inputtext)
|
16 |
+
if user == 'elonmusk':
|
17 |
+
tweet = jacobe(inputtext)
|
18 |
+
if user == 'realdonaldtrump':
|
19 |
+
tweet = donaldtrump(inputtext)
|
20 |
+
if user == 'karpathy':
|
21 |
+
tweet = karpathy(inputtext)
|
22 |
+
if user == 'barackobama':
|
23 |
+
tweet = barackobama(inputtext)
|
24 |
+
|
25 |
+
return tweet
|
26 |
+
|
27 |
+
title = "GPT-2 Tweet Generator"
|
28 |
+
|
29 |
+
description = "<p style='text-align: center'>GPT-2 Tweet Generator Hugging Face Demo. Simply select a twitter account you want to impersonate and input a word/phrase to generate a tweet.</p>"
|
30 |
+
|
31 |
+
article = "<p style='text-align: center'>Model built by Boris Dayma, https://github.com/borisdayma/huggingtweets</p>"
|
32 |
+
|
33 |
+
examples = [
|
34 |
+
['I have a dream','elonmusk'],
|
35 |
+
['I woke up feeling like', 'karpathy'],
|
36 |
+
['The world is a', 'jacobe' ]
|
37 |
+
]
|
38 |
+
|
39 |
+
|
40 |
+
gr.Interface(
|
41 |
+
generated_tweet,
|
42 |
+
[gr.inputs.Textbox(label="Input text",lines=5),
|
43 |
+
gr.inputs.Dropdown(choices=["baguioni","jacobe", "elonmusk", "realdonaldtrump"], type="value", default="baguioni", label="user")],
|
44 |
+
[gr.outputs.Label(label="Output")],
|
45 |
+
examples=examples,
|
46 |
+
article=article,
|
47 |
+
title=title,
|
48 |
+
description=description).launch(enable_queue=False)
|