QuindeelFatima's picture
Create app.py
6db9c1d verified
raw
history blame
798 Bytes
import streamlit as st
from transformers import pipeline
# Load the pre-trained language model
generator = pipeline("text-generation", model="gpt-2")
# Streamlit app
st.title("Blog Post Generator")
st.write("Generate a blog post for a given topic using GPT-2.")
# Input for the blog post topic
topic = st.text_input("Enter a blog post topic:")
if st.button("Generate"):
if topic:
# Generate a blog post based on the given topic
with st.spinner("Generating blog post..."):
result = generator(f"Blog post topic: {topic}\n\nBlog post content:", max_length=500)
blog_post = result[0]['generated_text']
st.subheader("Generated Blog Post")
st.write(blog_post)
else:
st.warning("Please enter a topic to generate the blog post.")