| import torch | |
| from transformers import pipeline | |
| import gradio as gr | |
| def generating_text(txt): | |
| device = torch.device("cpu") | |
| pipe = pipeline( | |
| "text-generation", model="checkpoint-5000", device=device | |
| ) | |
| return pipe(txt, num_return_sequences=1)[0]["generated_text"] | |
| demo = gr.Interface(fn=generating_text, inputs="text", outputs="text") | |
| demo.launch(inline=False) | |