mygen / app.py
ZenithBrew's picture
Update app.py
cdaf644 verified
raw
history blame
569 Bytes
import gradio as gr
from transformers import pipeline
# Load the text generation model
generator = pipeline('text-generation', model='gpt2')
# Function to generate text
def generate_text(prompt):
output = generator(prompt, max_length=50, num_return_sequences=1)
return output[0]['generated_text']
# Build the interface
iface = gr.Interface(
fn=generate_text,
inputs=gr.Textbox(lines=2, placeholder="Enter a prompt here..."),
outputs="text",
title="AI Text Generator",
description="Generate text with AI!"
)
# Launch it now
iface.launch()