Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
# Load the Hugging Face pipeline | |
nlp_pipeline = pipeline("text-generation", model="gpt2") | |
# Streamlit app title and description | |
st.title("Hugging Face Streamlit Demo") | |
st.write("This app demonstrates how to use Hugging Face's models with Streamlit.") | |
# User input for text generation | |
user_input = st.text_input("Enter some text:", "") | |
# Generate text using the Hugging Face model | |
if user_input: | |
generated_text = nlp_pipeline(user_input, max_length=50, num_return_sequences=1) | |
st.write("Generated Text:") | |
st.write(generated_text[0]['generated_text']) |