Dusan commited on
Commit
fd98557
1 Parent(s): e8de3d8

Adding input_example

Browse files
Files changed (1) hide show
  1. app.py +7 -6
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,13 @@ 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,7 +113,7 @@ 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
  )
 
 
 
 
 
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
+ textbox = gradio.inputs.Textbox(preprocessing_fn=preprocessing,
85
+ sample_inputs=[input_example])
86
+
87
+
88
  def clickbait_generator(article_content, condition_lambda=5.0):
 
89
  results = generate_clickbait(model=generation_model,
90
  tokenizer=tokenizer,
91
  conditioning_model=conditioning_model,
 
113
  description = description,
114
  label = 'Article content or paragraph',
115
  fn = clickbait_generator,
116
+ inputs=[textbox, gr.Slider(0, 15, step=0.1, value=5.0)],
117
  outputs="text",
118
  article=article,
119
  )