Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
|
| 5 |
+
device = torch.device("cpu")
|
| 6 |
+
pipe = pipeline(
|
| 7 |
+
"text-generation", model="/content/distilgpt2-finetuned-causal/checkpoint-5000", device=device
|
| 8 |
+
)
|
| 9 |
+
txt = "I do not like going to bank but I like"
|
| 10 |
+
print(pipe(txt, num_return_sequences=1)[0]["generated_text"])
|