yousifalishah commited on
Commit
6ffcf42
·
verified ·
1 Parent(s): 2f6016b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Load text-generation pipeline from Hugging Face
5
+ generator = pipeline("text-generation", model="gpt2")
6
+
7
+ # Streamlit App UI
8
+ st.set_page_config(page_title="AI Text Generator", page_icon="📝")
9
+ st.title("📝 AI Text Generator with GPT-2")
10
+
11
+ # User Input
12
+ prompt = st.text_area("Enter a prompt:", "Once upon a time")
13
+
14
+ # Generate Text Button
15
+ if st.button("Generate Text"):
16
+ with st.spinner("Generating..."):
17
+ result = generator(prompt, max_length=100, num_return_sequences=1)
18
+ st.subheader("Generated Text:")
19
+ st.write(result[0]["generated_text"])