pavan01729's picture
Update app.py
f4d8eae verified
raw
history blame contribute delete
No virus
603 Bytes
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()