Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -224,10 +224,11 @@ st.markdown("""
|
|
224 |
/* Primary title styling */
|
225 |
.main-title {
|
226 |
color: #E91E63;
|
227 |
-
font-size:
|
228 |
text-align: center;
|
229 |
-
padding:
|
230 |
text-shadow: 2px 2px #FFC107;
|
|
|
231 |
}
|
232 |
|
233 |
/* Prompt buttons styling */
|
@@ -247,6 +248,15 @@ st.markdown("""
|
|
247 |
margin: 20px 0;
|
248 |
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
249 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
/* Progress spinner styling */
|
252 |
.stSpinner > div {
|
@@ -290,7 +300,7 @@ if uploaded_image is not None:
|
|
290 |
help="Generate educational story with life lessons",
|
291 |
key="edu_btn"):
|
292 |
st.session_state.selected_prompt = "educational"
|
293 |
-
st.session_state.confirmed = False
|
294 |
with col2:
|
295 |
if st.button("π Fantasy Adventure",
|
296 |
help="Create magical adventure story",
|
@@ -314,6 +324,16 @@ if uploaded_image is not None:
|
|
314 |
|
315 |
# Only show generation when confirmed
|
316 |
if st.session_state.get('confirmed', False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
# Define prompt templates
|
318 |
PROMPT_TEMPLATES = {
|
319 |
"educational": {
|
@@ -335,10 +355,7 @@ if uploaded_image is not None:
|
|
335 |
|
336 |
# Story generation section
|
337 |
with st.spinner(f"{PROMPT_TEMPLATES[selected_prompt]['icon']} Creating your story..."):
|
338 |
-
# Generate
|
339 |
-
image_caption = generate_image_caption(image)
|
340 |
-
|
341 |
-
# Generate story content
|
342 |
selected_template = PROMPT_TEMPLATES[selected_prompt]
|
343 |
story_text = generate_story_content(
|
344 |
system_prompt=selected_template["system"],
|
@@ -366,6 +383,6 @@ st.info("""
|
|
366 |
1. Upload any picture (animals, nature, or people work best!)
|
367 |
2. Choose your favorite story style
|
368 |
3. Click the confirmation button
|
369 |
-
4. Wait for
|
370 |
-
5.
|
371 |
""")
|
|
|
224 |
/* Primary title styling */
|
225 |
.main-title {
|
226 |
color: #E91E63;
|
227 |
+
font-size: 7rem; /* Increased title size */
|
228 |
text-align: center;
|
229 |
+
padding: 30px;
|
230 |
text-shadow: 2px 2px #FFC107;
|
231 |
+
margin-bottom: 2rem;
|
232 |
}
|
233 |
|
234 |
/* Prompt buttons styling */
|
|
|
248 |
margin: 20px 0;
|
249 |
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
|
250 |
}
|
251 |
+
|
252 |
+
/* Image caption styling */
|
253 |
+
.image-caption {
|
254 |
+
border-left: 4px solid #4CAF50;
|
255 |
+
padding-left: 1rem;
|
256 |
+
font-size: 1.1rem;
|
257 |
+
color: #2c3e50;
|
258 |
+
margin: 1.5rem 0;
|
259 |
+
}
|
260 |
|
261 |
/* Progress spinner styling */
|
262 |
.stSpinner > div {
|
|
|
300 |
help="Generate educational story with life lessons",
|
301 |
key="edu_btn"):
|
302 |
st.session_state.selected_prompt = "educational"
|
303 |
+
st.session_state.confirmed = False
|
304 |
with col2:
|
305 |
if st.button("π Fantasy Adventure",
|
306 |
help="Create magical adventure story",
|
|
|
324 |
|
325 |
# Only show generation when confirmed
|
326 |
if st.session_state.get('confirmed', False):
|
327 |
+
# Generate image caption with loading state
|
328 |
+
with st.spinner("π Analyzing image and generating description..."):
|
329 |
+
image_caption = generate_image_caption(image)
|
330 |
+
|
331 |
+
# Display caption results using CSS class
|
332 |
+
st.subheader("π Image Understanding")
|
333 |
+
st.markdown(f'<div class="story-container image-caption">{image_caption}</div>',
|
334 |
+
unsafe_allow_html=True)
|
335 |
+
st.write("") # Add spacing
|
336 |
+
|
337 |
# Define prompt templates
|
338 |
PROMPT_TEMPLATES = {
|
339 |
"educational": {
|
|
|
355 |
|
356 |
# Story generation section
|
357 |
with st.spinner(f"{PROMPT_TEMPLATES[selected_prompt]['icon']} Creating your story..."):
|
358 |
+
# Generate story content using the caption
|
|
|
|
|
|
|
359 |
selected_template = PROMPT_TEMPLATES[selected_prompt]
|
360 |
story_text = generate_story_content(
|
361 |
system_prompt=selected_template["system"],
|
|
|
383 |
1. Upload any picture (animals, nature, or people work best!)
|
384 |
2. Choose your favorite story style
|
385 |
3. Click the confirmation button
|
386 |
+
4. Wait for image analysis to complete
|
387 |
+
5. Enjoy your personalized story and audio!
|
388 |
""")
|