Spaces:
Runtime error
Runtime error
import gradio as gr | |
from transformers import pipeline | |
text_generator = pipeline('text-generation', model='gpt2') | |
def generate_text(prompt): | |
response = text_generator(prompt, max_length=50, num_return_sequences=2) | |
return response[0]["generated_text"] | |
example_prompts = [ | |
["The Earth is a big"], | |
["70% of the Earth is covered by"], | |
] | |
demo_interface = gr.Interface( | |
fn=generate_text, | |
inputs=gr.inputs.Textbox(lines=5, label="Input Text"), | |
outputs=gr.outputs.Textbox(label="Generated Text"), | |
examples=example_prompts | |
) | |
demo_interface.launch() | |