Spaces:
Build error
Build error
| import gradio as gr | |
| from transformers import pipeline | |
| generator = pipeline("text-generation", model="distilgpt2") | |
| def generate_text(prompt): | |
| result = generator(prompt, max_length=50, num_return_sequences=1) | |
| return result[0]["generated_text"] | |
| iface = gr.Interface( | |
| fn=generate_text, | |
| inputs=gr.Textbox(lines=2, placeholder="Enter your prompt..."), | |
| outputs="text", | |
| title="Text Generation with DistilGPT2", | |
| description="Enter a prompt and generate text using the HuggingFace Transformers pipeline." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() |