Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Initialize Hugging Face pipeline | |
| nlp = pipeline('text-generation', model='gpt2') | |
| def generate_text(input_text): | |
| # Generate text using Hugging Face's GPT-2 model | |
| output_text = nlp(input_text)[0]['generated_text'] | |
| return output_text | |
| # Create Gradio Interface | |
| iface = gr.Interface( | |
| fn=generate_text, | |
| inputs=gr.Textbox(lines=2, placeholder='Enter Text Here...', max_lines=5), | |
| outputs='text' | |
| ) | |
| iface.launch() |