sabssag commited on
Commit
9afd04f
·
verified ·
1 Parent(s): e75ce8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -6,6 +6,9 @@ model_name = 'gpt2-large'
6
  tokenizer = GPT2Tokenizer.from_pretrained(model_name)
7
  model = GPT2LMHeadModel.from_pretrained(model_name)
8
 
 
 
 
9
  # Text input for the user
10
  text = st.text_area("Enter your Topic: ")
11
 
@@ -26,11 +29,17 @@ if text:
26
 
27
  # Decode generated text
28
  generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
29
- st.json(generated_text)
 
 
 
30
  except Exception as e:
31
  st.error(f"An error occurred: {e}")
32
 
33
- # # Add instructions
34
- # st.write("""
35
- # Enter a topic or a starting sentence in the text area above, and the GPT-2 model will generate a blog post for you.
36
- # """)
 
 
 
 
6
  tokenizer = GPT2Tokenizer.from_pretrained(model_name)
7
  model = GPT2LMHeadModel.from_pretrained(model_name)
8
 
9
+ # Set the title for the Streamlit app
10
+ st.title("GPT-2 Blog Post Generator")
11
+
12
  # Text input for the user
13
  text = st.text_area("Enter your Topic: ")
14
 
 
29
 
30
  # Decode generated text
31
  generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
32
+
33
+ # Display the generated text
34
+ st.subheader("Generated Blog Post")
35
+ st.write(generated_text)
36
  except Exception as e:
37
  st.error(f"An error occurred: {e}")
38
 
39
+ # Add instructions
40
+ st.write("""
41
+ Enter a topic or a starting sentence in the text area above, and the GPT-2 model will generate a blog post for you.
42
+ """)
43
+
44
+ # Streamlit instructions
45
+ st.write("To run this app, use the command: `streamlit run <script_name>.py`")