mkoot007 commited on
Commit
7961c47
·
1 Parent(s): 288456a

Create aap.py

Browse files
Files changed (1) hide show
  1. aap.py +27 -0
aap.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Create a text generation pipeline
5
+ pipe = pipeline("text-generation", model="ismaelfaro/gpt2-poems.en")
6
+
7
+ # Define the Streamlit app
8
+ st.title("Text Generation with Hugging Face Transformers")
9
+
10
+ # Input for user to provide a seed text
11
+ seed_text = st.text_input("Enter a seed text:")
12
+
13
+ # Button to generate text
14
+ if st.button("Generate Text"):
15
+ if seed_text:
16
+ generated_text = pipe(seed_text, max_length=50, do_sample=True)[0]['generated_text']
17
+ st.write("Generated Text:")
18
+ st.write(generated_text)
19
+ else:
20
+ st.write("Please enter a seed text to generate text.")
21
+
22
+ # Instructions and information
23
+ st.markdown("This app uses the Hugging Face Transformers library for text generation.")
24
+ st.markdown("Model: ismaelfaro/gpt2-poems.en")
25
+
26
+ # Provide additional information or options here
27
+