import gradio as gr from transformers import pipeline generator = pipeline('text-generation', model='gpt2') def generate_text(inp): return generator(inp, max_length=50, do_sample=True, temperature=0.7)[0]['generated_text'] iface = gr.Interface(fn=generate_text, inputs="textbox", outputs="text") iface.launch()