Spaces:
Runtime error
Runtime error
import streamlit as st | |
from transformers import pipeline | |
# Load your model; this example uses the GPT-2 model for text generation. | |
generator = pipeline('text-generation', model='gpt2') | |
st.title('Hugging Face Model Integration') | |
# Text input | |
user_input = st.text_input("Type a sentence to complete", "Streamlit is ") | |
# Generate text button | |
if st.button('Generate'): | |
# Generate text | |
result = generator(user_input, max_length=50, num_return_sequences=1) | |
# Display the generated text | |
st.text_area("Generated Text", result[0]['generated_text'], height=150) | |