File size: 1,744 Bytes
4a4795b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import gradio as gr

# Models
jacobe = gr.Interface.load(f"huggingface/huggingtweets/jacobe")
baguioni = gr.Interface.load(f"huggingface/huggingtweets/baguioni")
elonmusk = gr.Interface.load(f"huggingface/huggingtweets/elonmusk")
realdonaldtrump = gr.Interface.load(f"huggingface/huggingtweets/realdonaldtrump")
barackobama = gr.Interface.load(f"huggingface/huggingtweets/barackobama")
karpathy = gr.Interface.load(f"huggingface/huggingtweets/karpathy")

def generated_tweet(inputtext, user):
    if user == 'jacobe':
      tweet = jacobe(inputtext)
    if user == 'baguioni':
      tweet = baguioni(inputtext)
    if user == 'elonmusk':
      tweet = jacobe(inputtext)
    if user == 'realdonaldtrump':
      tweet = donaldtrump(inputtext)
    if user == 'karpathy':
      tweet = karpathy(inputtext)
    if user == 'barackobama':
      tweet = barackobama(inputtext)
    return tweet

title = "GPT-2 Tweet Generator"

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>"

article = "<p style='text-align: center'>Model built by Boris Dayma, https://github.com/borisdayma/huggingtweets</p>"

examples = [
    ['I have a dream','elonmusk'],
    ['I woke up feeling like', 'karpathy'],
    ['The world is a', 'jacobe' ]
]


gr.Interface(
    generated_tweet, 
    [gr.inputs.Textbox(label="Input text",lines=5),
     gr.inputs.Dropdown(choices=["baguioni","jacobe", "elonmusk", "realdonaldtrump"], type="value", default="baguioni", label="user")], 
    [gr.outputs.Label(label="Output")],
    examples=examples,
    article=article,
    title=title,
    description=description).launch(enable_queue=False)