g3casey commited on
Commit
9ea3a53
·
1 Parent(s): 12f0210

update Initial app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -18,7 +18,7 @@ text = """All of this is right here, ready to be used
18
  in your favorite pizza recipes."""
19
 
20
  def get_story(text):
21
-
22
  input_ids = torch.tensor(gpt2_tokenizer.encode(text, add_special_tokens=True)).unsqueeze(0) # bs=1
23
 
24
  gpt2_model.to(device)
@@ -31,18 +31,21 @@ def get_story(text):
31
  top_k=20,
32
  temperature=0.7
33
  )
 
 
34
 
35
  # print(gpt2_tokenizer.decode(outputs[0], skip_special_tokens=True))
36
  # outputs.shape,outputs[0].shape # (torch.Size([1, 500]), torch.Size([500]))
37
-
38
 
39
  input = gr.Textbox(lines=2, placeholder="Start your story here...", label='Story starter')
40
- output = gr.Textbox(label='The Big Story')
41
 
42
  iface = gr.Interface(fn=get_story,
43
  inputs=input,
44
  outputs=output,
45
  title='The Complete Story',
46
- description='Enter the beginning of your story and we will finish it for you.'
 
47
  )
48
  iface.launch()
 
18
  in your favorite pizza recipes."""
19
 
20
  def get_story(text):
21
+ print(text)
22
  input_ids = torch.tensor(gpt2_tokenizer.encode(text, add_special_tokens=True)).unsqueeze(0) # bs=1
23
 
24
  gpt2_model.to(device)
 
31
  top_k=20,
32
  temperature=0.7
33
  )
34
+ print(f'outputs: {gpt2_tokenizer.decode(outputs[0], skip_special_tokens=True)}')
35
+ return(gpt2_tokenizer.decode(outputs[0], skip_special_tokens=True))
36
 
37
  # print(gpt2_tokenizer.decode(outputs[0], skip_special_tokens=True))
38
  # outputs.shape,outputs[0].shape # (torch.Size([1, 500]), torch.Size([500]))
39
+ # In the dark night he effortlessly climbed into the spacecraft and closed the ramped door.
40
 
41
  input = gr.Textbox(lines=2, placeholder="Start your story here...", label='Story starter')
42
+ output = gr.Textbox(label='The Big Story', lines=300)
43
 
44
  iface = gr.Interface(fn=get_story,
45
  inputs=input,
46
  outputs=output,
47
  title='The Complete Story',
48
+ description='Enter the beginning of your story and we will finish it for you.',
49
+ sample_inputs='In the dark night he effortlessly climbed into the spacecraft and closed the ramped door.'
50
  )
51
  iface.launch()