QuindeelFatima commited on
Commit
6db9c1d
·
verified ·
1 Parent(s): 2fe4240

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load the pre-trained language model
5
+ generator = pipeline("text-generation", model="gpt-2")
6
+
7
+ # Streamlit app
8
+ st.title("Blog Post Generator")
9
+ st.write("Generate a blog post for a given topic using GPT-2.")
10
+
11
+ # Input for the blog post topic
12
+ topic = st.text_input("Enter a blog post topic:")
13
+
14
+ if st.button("Generate"):
15
+ if topic:
16
+ # Generate a blog post based on the given topic
17
+ with st.spinner("Generating blog post..."):
18
+ result = generator(f"Blog post topic: {topic}\n\nBlog post content:", max_length=500)
19
+ blog_post = result[0]['generated_text']
20
+ st.subheader("Generated Blog Post")
21
+ st.write(blog_post)
22
+ else:
23
+ st.warning("Please enter a topic to generate the blog post.")