rafaym commited on
Commit
546ccd4
·
1 Parent(s): a35b0c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,15 +3,15 @@ import torch
3
  from transformers import pipeline
4
  import gradio as gr
5
 
6
- def greet(txt):
7
  device = torch.device("cpu")
8
  pipe = pipeline(
9
  "text-generation", model="checkpoint-5000", device=device
10
  )
11
- return txt + " "+ pipe(txt, num_return_sequences=1)[0]["generated_text"]
12
 
13
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
14
 
15
- demo.launch()
16
  # device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
17
 
 
3
  from transformers import pipeline
4
  import gradio as gr
5
 
6
+ def generating_text(txt):
7
  device = torch.device("cpu")
8
  pipe = pipeline(
9
  "text-generation", model="checkpoint-5000", device=device
10
  )
11
+ return pipe(txt, num_return_sequences=1)[0]["generated_text"]
12
 
13
+ demo = gr.Interface(fn=generating_text, inputs="text", outputs="text")
14
 
15
+ demo.launch(share=True)
16
  # device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
17