File size: 569 Bytes
51b35bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cdaf644
51b35bd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()