Update app.py
Browse files
app.py
CHANGED
|
@@ -3,15 +3,15 @@ import torch
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
-
def
|
| 7 |
device = torch.device("cpu")
|
| 8 |
pipe = pipeline(
|
| 9 |
"text-generation", model="checkpoint-5000", device=device
|
| 10 |
)
|
| 11 |
-
return
|
| 12 |
|
| 13 |
-
demo = gr.Interface(fn=
|
| 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 |
|