DarwinAnim8or commited on
Commit
af20dc1
·
1 Parent(s): 3b33fc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -5,9 +5,10 @@ from happytransformer import HappyGeneration
5
  happy_gen = HappyGeneration("GPT2", "DarwinAnim8or/GPT-Greentext-355m")
6
 
7
  from happytransformer import GENSettings
8
- args_top_k = GENSettings(no_repeat_ngram_size=3, do_sample=True, top_k=80, temperature=0.8, max_length=150, early_stopping=False)
9
 
10
- def generate(text):
 
 
11
  inputText = "" #"Write a greentext from 4chan.org. The story should be like a bullet-point list using > as the start of each line. Most greentexts are humorous or absurd in nature. Most greentexts have a twist near the end.\n"
12
  inputText += ">" + text + "\n>"
13
 
@@ -30,12 +31,16 @@ examples = [
30
  ["be going to heaven"],
31
  ["be going to work"],
32
  ["be baking a pie"],
33
- ["come home after another tiring day"]
 
34
  ]
35
 
36
  demo = gr.Interface(
37
  fn=generate,
38
  inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
 
 
 
39
  outputs=gr.outputs.Textbox(label="Generated Text"),
40
  examples=examples,
41
  title="GPT-Greentext Playground",
 
5
  happy_gen = HappyGeneration("GPT2", "DarwinAnim8or/GPT-Greentext-355m")
6
 
7
  from happytransformer import GENSettings
 
8
 
9
+ def generate(text, length=100, temperature=0.8):
10
+ args_top_k = GENSettings(no_repeat_ngram_size=3, do_sample=True, top_k=80, temperature=temperature, max_length=length, early_stopping=False)
11
+
12
  inputText = "" #"Write a greentext from 4chan.org. The story should be like a bullet-point list using > as the start of each line. Most greentexts are humorous or absurd in nature. Most greentexts have a twist near the end.\n"
13
  inputText += ">" + text + "\n>"
14
 
 
31
  ["be going to heaven"],
32
  ["be going to work"],
33
  ["be baking a pie"],
34
+ ["come home after another tiring day"],
35
+ ["be a plague doctor"]
36
  ]
37
 
38
  demo = gr.Interface(
39
  fn=generate,
40
  inputs=gr.inputs.Textbox(lines=5, label="Input Text"),
41
+ gr.inputs.Slider(1, 200, label='Length', default=100, step=5),
42
+ gr.inputs.Slider(0.0, 1.0, label='Temperature - control randomness', default=0.8, step=0.1),
43
+ gen_button = gr.Button("Generate")
44
  outputs=gr.outputs.Textbox(label="Generated Text"),
45
  examples=examples,
46
  title="GPT-Greentext Playground",