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