Spaces:
Runtime error
Runtime error
File size: 556 Bytes
f5f855c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import gradio as gr
from transformers import pipeline
# Load the Hugging Face model
model = pipeline("text-generation", model="distilgpt2")
def generate_text(prompt):
generated_text = model(prompt, max_length=50)[0]['generated_text']
return generated_text
textbox = gr.inputs.Textbox(lines=7, label="Enter a prompt")
output_text = gr.outputs.Textbox(label="Generated Text")
gr.Interface(fn=generate_text, inputs=textbox, outputs=output_text, title="Hugging Face Text Generation", description="Generate text using a Hugging Face model").launch() |