File size: 603 Bytes
40c4f97
f4d8eae
40c4f97
f4d8eae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Use a smaller, publicly available model
model_name = "gpt2"  # You can change this to another suitable model

# Create a text generation pipeline
generator = pipeline('text-generation', model=model_name)

def generate_text(prompt):
    result = generator(prompt, max_length=100, num_return_sequences=1)
    return result[0]['generated_text']

iface = gr.Interface(
    fn=generate_text,
    inputs="text",
    outputs="text",
    title="Text Generation with GPT-2",
    description="Enter a prompt to generate text using GPT-2."
)

iface.launch()