JDmayo commited on
Commit
c9d5944
·
verified ·
1 Parent(s): d74a893

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -7
app.py CHANGED
@@ -1,9 +1,23 @@
1
- import streamlit as st
2
- from transformers import pipeline
3
 
4
- pipe = pipeline('sentiment-analysis')
5
- text = st.text_area("Enter your text")
6
 
7
- if text:
8
- out = pipe(text)
9
- st.write(out)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Initialize the text-generation pipeline with a pre-trained model (e.g., GPT-2)
5
+ generator = pipeline("text-generation", model="gpt-2")
6
 
7
+ def generate_blogpost(topic):
8
+ prompt = f"Write a detailed blog post about {topic}."
9
+ result = generator(prompt, max_length=300, num_return_sequences=1)
10
+ return result[0]['generated_text']
11
+
12
+ # Define the Gradio interface
13
+ iface = gr.Interface(
14
+ fn=generate_blogpost,
15
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter blog topic here..."),
16
+ outputs="text",
17
+ title="Blog Post Generator",
18
+ description="Generate a detailed blog post for a given topic using GPT-2."
19
+ )
20
+
21
+ # Launch the Gradio interface
22
+ if __name__ == "__main__":
23
+ iface.launch()