Dusan commited on
Commit
751cb83
·
1 Parent(s): c4ebaf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -1,7 +1,3 @@
1
- # import os
2
-
3
- # os.chdir('naacl-2021-fudge-controlled-generation/')
4
-
5
  import gradio as gr
6
  from fudge.predict_clickbait import generate_clickbait, tokenizer, classifier_tokenizer
7
  from datasets import load_dataset,DatasetDict,Dataset
@@ -83,8 +79,16 @@ def preprocess_function_title_only_classification(examples,tokenizer=None):
83
 
84
 
85
 
 
 
 
 
 
 
 
 
 
86
  def clickbait_generator(article_content, condition_lambda=5.0):
87
- # result = "Hi {}! 😎. The Mulitple of {} is {}".format(name, number, round(number**2, 2))
88
  results = generate_clickbait(model=generation_model,
89
  tokenizer=tokenizer,
90
  conditioning_model=conditioning_model,
@@ -112,8 +116,8 @@ app = gr.Interface(
112
  description = description,
113
  label = 'Article content or paragraph',
114
  fn = clickbait_generator,
115
- inputs=["text", gr.Slider(0, 15, step=0.1, value=5.0)],
116
- outputs="text",
117
  article=article,
118
  )
119
  app.launch()
 
 
 
 
 
1
  import gradio as gr
2
  from fudge.predict_clickbait import generate_clickbait, tokenizer, classifier_tokenizer
3
  from datasets import load_dataset,DatasetDict,Dataset
 
79
 
80
 
81
 
82
+ input_example = "On Friday, a clip of Los Angeles Lakers star LeBron James from the latest episode of \"The Shop: Uninterrupted\" is going viral on Twitter. \"Cause they racist as f--k,\" James said when asked why he hates Boston. James has had many battles with the Boston Celtics in the NBA Playoffs. According to StatMuse, he has played the Celtics 41 times in the NBA Playoffs. He's played them in the playoffs when he was on the Cleveland Cavaliers (the first time), the Miami Heat and the Cavs (the second time). Therefore, he has had quite the experience facing off with them in hostile environments. He is 25-16 against them in the 41 playoff games and averaged 29.6 points per game. (also according to StatMuse). James is currently on the Los Angeles Lakers, and the team missed the postseason this past year. They were the 11th seed in the Western Conference, so they also missed the play-in tournament which was a big surprise. His first year in Los Angeles, they also missed the playoffs, but the following season he led them to their first NBA Championship since the 2010 season. In 2021, they lost in the first-round, so they have been on a downward trajectory since winning the title. Next season will be his 20th season in the NBA, and he is widely regarded as one of the top-five (and to some the greatest) player ever to play the game of basketball. He is 37-years-old, and was the first overall pick out of high school in the 2003 NBA Draft. "
83
+
84
+ output_example = "Here's why Lebron James hates the Celtics"
85
+ textbox_input = gr.Textbox(label = "Article content",
86
+ value=input_example)
87
+ textbox_output = gr.Textbox(label = "Output clickbait title",
88
+ value=output_example)
89
+
90
+
91
  def clickbait_generator(article_content, condition_lambda=5.0):
 
92
  results = generate_clickbait(model=generation_model,
93
  tokenizer=tokenizer,
94
  conditioning_model=conditioning_model,
 
116
  description = description,
117
  label = 'Article content or paragraph',
118
  fn = clickbait_generator,
119
+ inputs=[textbox_input, gr.Slider(0, 15, step=0.1, value=5.0)],
120
+ outputs=textbox_output,
121
  article=article,
122
  )
123
  app.launch()