Spaces:
Sleeping
Sleeping
File size: 592 Bytes
2f935de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
import gradio as gr
from transformers import pipeline
# Load a pre-trained text generation model from Hugging Face
generator = pipeline('text-generation', model='gpt2')
def generate_text(prompt):
# Generate text using the model
result = generator(prompt, max_length=100, num_return_sequences=1)
return result[0]['generated_text']
# Create a Gradio interface
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text", title="Text Generator", description="Enter a prompt to generate text.")
# Launch the interface
if __name__ == "__main__":
interface.launch() |