mkoot007 commited on
Commit
03be16d
1 Parent(s): 8e65c11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -1,19 +1,27 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
 
4
- # Create a text2text-generation pipeline with the "google/flan-t5-base" model
5
- paraphrase_generator = pipeline("text2text-generation", model="google/flan-t5-base")
6
 
7
- st.title("Paraphrase Generator")
 
8
 
9
- user_input = st.text_input("Enter a line:")
 
10
 
11
- if st.button("Generate Paraphrase"):
12
- if user_input:
13
- # Use a prompt to control the paraphrasing
14
- paraphrase_prompt = f"Paraphrase the following line: '{user_input}'"
15
- paraphrase = paraphrase_generator(paraphrase_prompt, max_length=100, do_sample=True)[0]["generated_text"]
16
- st.markdown("**Paraphrase:**")
17
- st.markdown(paraphrase)
18
  else:
19
- st.warning("Please enter a line.")
 
 
 
 
 
 
 
 
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
+