Spaces:
Sleeping
Sleeping
File size: 850 Bytes
f2c8d49 338b4ff f2c8d49 |
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 29 |
import streamlit as st
from transformers import pipeline
# Load GPT-2 model and tokenizer
@st.cache(allow_output_mutation=True)
def load_model():
return pipeline("text-generation", model="gpt-2")
model = load_model()
st.title("Blog Post Generator")
st.write("Generate a blog post for a given topic using GPT-2.")
# User input for the blog post topic
topic = st.text_input("Enter the topic for your blog post:")
# Generate blog post button
if st.button("Generate Blog Post"):
if topic:
# Generate the blog post using GPT-2
result = model(f"Write a blog post about {topic}.", max_length=500, num_return_sequences=1)
blog_post = result[0]['generated_text']
st.write("### Generated Blog Post:")
st.write(blog_post)
else:
st.write("Please enter a topic to generate a blog post.")
|