File size: 868 Bytes
67448d5 8e65c11 bc75555 03be16d 67448d5 03be16d 8e65c11 03be16d bc75555 03be16d 67448d5 03be16d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import streamlit as st
from transformers import pipeline
# Create a text generation pipeline
pipe = pipeline("text-generation", model="ismaelfaro/gpt2-poems.en")
# Define the Streamlit app
st.title("Text Generation with Hugging Face Transformers")
# Input for user to provide a seed text
seed_text = st.text_input("Enter a seed text:")
# Button to generate text
if st.button("Generate Text"):
if seed_text:
generated_text = pipe(seed_text, max_length=50, do_sample=True)[0]['generated_text']
st.write("Generated Text:")
st.write(generated_text)
else:
st.write("Please enter a seed text to generate text.")
# Instructions and information
st.markdown("This app uses the Hugging Face Transformers library for text generation.")
st.markdown("Model: ismaelfaro/gpt2-poems.en")
# Provide additional information or options here
|