Spaces:
Sleeping
Sleeping
File size: 536 Bytes
562f402 e23f61a 562f402 e23f61a 562f402 e23f61a 562f402 e23f61a 562f402 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from transformers import pipeline
# Load a pre-trained Hugging Face model
generator = pipeline("text-generation", model="gpt2")
def generate_text(prompt):
# Generate text using the model
result = generator(prompt, max_length=50, num_return_sequences=1)
return result[0]["generated_text"]
# Create the Gradio interface
iface = gr.Interface(
fn=generate_text,
inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
outputs=gr.Textbox()
)
# Launch the interface
iface.launch()
|