rafaym commited on
Commit
93303ed
·
1 Parent(s): e08bfbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -3,16 +3,15 @@ import torch
3
  from transformers import pipeline
4
  import gradio as gr
5
 
6
- def greet(name):
7
- return "Hello " + name + "!"
 
 
 
 
8
 
9
  demo = gr.Interface(fn=greet, inputs="text", outputs="text")
10
 
11
  demo.launch()
12
  # device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
13
- device = torch.device("cpu")
14
- pipe = pipeline(
15
- "text-generation", model="/content/distilgpt2-finetuned-causal/checkpoint-5000", device=device
16
- )
17
- txt = "I do not like going to bank but I like"
18
- print(pipe(txt, num_return_sequences=1)[0]["generated_text"])
 
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
+