Spaces:
Sleeping
Sleeping
File size: 622 Bytes
e644d85 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
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']) |