Santhosh54321 commited on
Commit
cd1164b
·
verified ·
1 Parent(s): 1f8970b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -21
app.py CHANGED
@@ -118,7 +118,7 @@ def main():
118
  """, unsafe_allow_html=True
119
  )
120
 
121
- st.title("🌐 Multimodal Generator")
122
 
123
  # Sidebar for temperature and token adjustment
124
  st.sidebar.header("Settings")
@@ -133,31 +133,37 @@ def main():
133
  # Input box for user
134
  tamil_input = st.text_input("Enter Tamil text (or select a suggestion):", selected_suggestion)
135
 
 
 
 
136
  if st.button("Generate"):
137
  # Step 1: Translation (Tamil to English)
138
  if tamil_input:
139
  st.write("### Translated English Text:")
140
  english_text = translate_text(tamil_input)
141
- if not english_text:
142
- english_text = st.text_input("Translation failed. Please enter English text instead:")
143
-
144
- if english_text:
145
- st.success(english_text)
146
-
147
- # Step 2: Generate Educational Content
148
- st.write("### Generated Educational Content:")
149
- with st.spinner('Generating content...'):
150
- content_output = generate_content(english_text, max_tokens, temperature)
151
- if content_output:
152
- st.success(content_output)
153
-
154
- # Step 3: Generate Image from the prompt
155
- st.write("### Generated Image:")
156
- with st.spinner('Generating image...'):
157
- image_prompt = generate_image_prompt(english_text)
158
- image_data = generate_image(image_prompt)
159
- if image_data:
160
- st.image(image_data, caption="Generated Image")
 
 
 
161
 
162
  if __name__ == "__main__":
163
  main()
 
118
  """, unsafe_allow_html=True
119
  )
120
 
121
+ st.title("🅰️ℹ️ Multimodal Generator")
122
 
123
  # Sidebar for temperature and token adjustment
124
  st.sidebar.header("Settings")
 
133
  # Input box for user
134
  tamil_input = st.text_input("Enter Tamil text (or select a suggestion):", selected_suggestion)
135
 
136
+ # Initialize a variable to store the English text
137
+ english_text = None
138
+
139
  if st.button("Generate"):
140
  # Step 1: Translation (Tamil to English)
141
  if tamil_input:
142
  st.write("### Translated English Text:")
143
  english_text = translate_text(tamil_input)
144
+
145
+ # If translation fails, ask for English input
146
+ if not english_text:
147
+ english_text = st.text_input("Translation failed. Please enter English text instead:")
148
+
149
+ # Ensure the English text is available
150
+ if english_text:
151
+ st.success(english_text)
152
+
153
+ # Step 2: Generate Educational Content
154
+ st.write("### Generated Educational Content:")
155
+ with st.spinner('Generating content...'):
156
+ content_output = generate_content(english_text, max_tokens, temperature)
157
+ if content_output:
158
+ st.success(content_output)
159
+
160
+ # Step 3: Generate Image from the prompt
161
+ st.write("### Generated Image:")
162
+ with st.spinner('Generating image...'):
163
+ image_prompt = generate_image_prompt(english_text)
164
+ image_data = generate_image(image_prompt)
165
+ if image_data:
166
+ st.image(image_data, caption="Generated Image")
167
 
168
  if __name__ == "__main__":
169
  main()