Spaces:
Runtime error
Runtime error
import streamlit as st | |
from transformers import pipeline | |
st.title("Text Generation with Hugging Face") | |
model_name = "gpt2" | |
generator = pipeline("text-generation", model=model_name, device=0) | |
prompt = st.text_input("Enter text prompt:", "Once upon a time") | |
if st.button("Generate Text"): | |
output = generator(prompt, max_length=100, do_sample=True) | |
st.write(output[0]['generated_text']) | |