File size: 1,750 Bytes
4a4795b
 
 
64445a4
 
 
 
 
 
4a4795b
 
ae54d30
4a4795b
64445a4
4a4795b
64445a4
4a4795b
64445a4
4a4795b
64445a4
4a4795b
64445a4
4a4795b
64445a4
 
4a4795b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64445a4
4a4795b
 
 
 
af117fa
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("huggingface/huggingtweets/jacobe")
baguioni = gr.Interface.load("huggingface/huggingtweets/baguioni")
elonmusk = gr.Interface.load("huggingface/huggingtweets/elonmusk")
realdonaldtrump = gr.Interface.load("huggingface/huggingtweets/realdonaldtrump")
barackobama = gr.Interface.load("huggingface/huggingtweets/barackobama")
karpathy = gr.Interface.load("huggingface/huggingtweets/karpathy")

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

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",lines=5), gr.inputs.Dropdown(choices=["baguioni","jacobe", "elonmusk", "realdonaldtrump", "barackobama", "karpathy"], type="value", default="baguioni", label="user")], 
    [gr.outputs.Label(label="Output")],
    examples=examples,
    article=article,
    title=title,
    description=description).launch()