import gradio as gr import torch from transformers import pipeline device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu") pipe = pipeline("text-generation", model="poem_generator3", device=device) def generate_poem(text): res = pipe(text)[0]["generated_text"] return res iface = gr.Interface( generate_poem, gr.Textbox(lines=5, label="Enter text to start the Poetic Lines"), gr.Textbox(label="Generated Poetic Lines") ) iface.launch()