MarwanAshraf22 commited on
Commit
4da3b8a
·
1 Parent(s): 9063d8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -20
app.py CHANGED
@@ -6,6 +6,7 @@ from nltk.corpus import wordnet
6
  import nltk
7
  nltk.download('wordnet')
8
 
 
9
  def generate_text(prompt, temperature=0.7, top_k=50, repetition_penalty=1.2, max_length=None, min_length=10):
10
  text_model = "gpt2"
11
  tokenizer = AutoTokenizer.from_pretrained(text_model)
@@ -80,37 +81,26 @@ try :
80
  new_image1 = generated_image1.resize((700, 500))
81
  st.image(new_image1, use_column_width=True)
82
 
 
 
 
83
  intro_text = generate_text(f'introduction about : {generated_text}', min_length=100, max_length=200)
84
  intro_text = intro_text.replace(f"introduction about : {generated_text}", "")
85
  st.write(intro_text.strip()) # Display the generated introduction text
86
 
87
- body_text1 = generate_text(f'article about : {generated_text}', min_length=100, max_length=150)
88
- body_text1 = body_text1.replace(f"article about : {generated_text}", "")
89
- st.write(body_text1.strip()) # Display the generated introduction text
90
-
91
- body_text2 = generate_text(f'article about : {generated_text}', min_length=200, max_length=300)
92
- body_text2 = body_text2.replace(f"{generated_text}", "")
93
- st.write(body_text2.strip()) # Display the generated introduction text
94
-
95
- conclusion_text = generate_text(f'conclusion about : {generated_text}', min_length=100, max_length=200)
96
- conclusion_text = conclusion_text.replace(f"conclusion about : {generated_text}", "")
97
- st.write(conclusion_text.strip()) # Display the generated introduction text
98
-
99
-
100
-
101
- st.subheader("Introduction")
102
- st.write(intro_text)
103
  modified_prompt = generated_text + 'bright'
104
  generated_image2 = generate_image(modified_prompt)
105
 
106
  new_image2 = generated_image2.resize((700, 300))
107
  st.image(new_image2, use_column_width=True)
108
 
109
-
110
  col1, col2 = st.columns(2)
111
  with col1:
112
  st.subheader("Body")
113
- st.write(body_text1)
 
 
114
 
115
  with col2:
116
  modified_prompt2 = generated_text + 'shade'
@@ -118,14 +108,22 @@ try :
118
  st.markdown("<br><br><br><br>", unsafe_allow_html=True)
119
  st.image(generated_image3, use_column_width=True)
120
 
121
- st.write(body_text2)
 
 
 
 
122
  modified_prompt3 = generated_text + title
123
  generated_image4 = generate_image(modified_prompt3)
124
  new_image3 = generated_image4.resize((700, 300))
125
  st.image(new_image3, use_column_width=True)
126
 
 
127
  st.subheader("Conclusion")
128
- st.write(conclusion_text)
 
 
 
129
  else:
130
  st.warning("Please input keywords to generate content.")
131
 
 
6
  import nltk
7
  nltk.download('wordnet')
8
 
9
+
10
  def generate_text(prompt, temperature=0.7, top_k=50, repetition_penalty=1.2, max_length=None, min_length=10):
11
  text_model = "gpt2"
12
  tokenizer = AutoTokenizer.from_pretrained(text_model)
 
81
  new_image1 = generated_image1.resize((700, 500))
82
  st.image(new_image1, use_column_width=True)
83
 
84
+
85
+ # Introduction
86
+ st.subheader("Introduction")
87
  intro_text = generate_text(f'introduction about : {generated_text}', min_length=100, max_length=200)
88
  intro_text = intro_text.replace(f"introduction about : {generated_text}", "")
89
  st.write(intro_text.strip()) # Display the generated introduction text
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  modified_prompt = generated_text + 'bright'
92
  generated_image2 = generate_image(modified_prompt)
93
 
94
  new_image2 = generated_image2.resize((700, 300))
95
  st.image(new_image2, use_column_width=True)
96
 
97
+ # Body 1
98
  col1, col2 = st.columns(2)
99
  with col1:
100
  st.subheader("Body")
101
+ body_text1 = generate_text(f'article about : {generated_text}', min_length=100, max_length=150)
102
+ body_text1 = body_text1.replace(f"article about : {generated_text}", "")
103
+ st.write(body_text1.strip()) # Display the generated introduction text
104
 
105
  with col2:
106
  modified_prompt2 = generated_text + 'shade'
 
108
  st.markdown("<br><br><br><br>", unsafe_allow_html=True)
109
  st.image(generated_image3, use_column_width=True)
110
 
111
+ # Body 2
112
+ body_text2 = generate_text(f'article about : {generated_text}', min_length=200, max_length=300)
113
+ body_text2 = body_text2.replace(f"{generated_text}", "")
114
+ st.write(body_text2.strip()) # Display the generated introduction text
115
+
116
  modified_prompt3 = generated_text + title
117
  generated_image4 = generate_image(modified_prompt3)
118
  new_image3 = generated_image4.resize((700, 300))
119
  st.image(new_image3, use_column_width=True)
120
 
121
+ # Conclusion
122
  st.subheader("Conclusion")
123
+ conclusion_text = generate_text(f'conclusion about : {generated_text}', min_length=100, max_length=200)
124
+ conclusion_text = conclusion_text.replace(f"conclusion about : {generated_text}", "")
125
+ st.write(conclusion_text.strip()) # Display the generated introduction text
126
+
127
  else:
128
  st.warning("Please input keywords to generate content.")
129