Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,7 +104,7 @@ st.markdown("""
|
|
| 104 |
}
|
| 105 |
.stButton>button {
|
| 106 |
background-color: #ffcccb;
|
| 107 |
-
color: #000000;
|
| 108 |
border-radius: 10px;
|
| 109 |
border: 2px solid #ff9999;
|
| 110 |
font-size: 18px;
|
|
@@ -114,38 +114,36 @@ st.markdown("""
|
|
| 114 |
}
|
| 115 |
.stButton>button:hover {
|
| 116 |
background-color: #ff9999;
|
| 117 |
-
color: #ffffff;
|
| 118 |
transform: scale(1.05);
|
| 119 |
}
|
| 120 |
.stFileUploader {
|
| 121 |
-
background-color: #ffb300;
|
| 122 |
-
border: 2px dashed #ff8c00;
|
| 123 |
border-radius: 10px;
|
| 124 |
padding: 10px;
|
| 125 |
}
|
| 126 |
-
/* Style for the file uploader's inner text */
|
| 127 |
.stFileUploader div[role="button"] {
|
| 128 |
-
background-color: #f0f0f0;
|
| 129 |
border-radius: 10px;
|
| 130 |
padding: 10px;
|
| 131 |
}
|
| 132 |
.stFileUploader div[role="button"] > div {
|
| 133 |
-
color: #000000 !important;
|
| 134 |
font-size: 16px;
|
| 135 |
}
|
| 136 |
-
/* Style for the "Browse files" button inside the file uploader */
|
| 137 |
.stFileUploader button {
|
| 138 |
-
background-color: #ffca28 !important;
|
| 139 |
-
color: #000000 !important;
|
| 140 |
border-radius: 8px !important;
|
| 141 |
-
border: 2px solid #ffb300 !important;
|
| 142 |
padding: 5px 15px !important;
|
| 143 |
font-weight: bold !important;
|
| 144 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
|
| 145 |
}
|
| 146 |
.stFileUploader button:hover {
|
| 147 |
-
background-color: #ff8c00 !important;
|
| 148 |
-
color: #000000 !important;
|
| 149 |
}
|
| 150 |
.stImage {
|
| 151 |
border: 3px solid #81c784;
|
|
@@ -159,7 +157,7 @@ st.markdown("""
|
|
| 159 |
text-align: center;
|
| 160 |
font-size: 24px;
|
| 161 |
font-weight: bold;
|
| 162 |
-
color: #000000;
|
| 163 |
margin-bottom: 10px;
|
| 164 |
}
|
| 165 |
.caption-box, .story-box {
|
|
@@ -168,10 +166,13 @@ st.markdown("""
|
|
| 168 |
border-radius: 10px;
|
| 169 |
border: 2px solid #d4e157;
|
| 170 |
margin-bottom: 20px;
|
| 171 |
-
color: #000000;
|
| 172 |
}
|
| 173 |
.caption-box b, .story-box b {
|
| 174 |
-
color: #000000;
|
|
|
|
|
|
|
|
|
|
| 175 |
}
|
| 176 |
</style>
|
| 177 |
""", unsafe_allow_html=True)
|
|
@@ -194,23 +195,38 @@ with st.spinner("Looking at your picture..."):
|
|
| 194 |
|
| 195 |
# Caption section
|
| 196 |
with st.container():
|
|
|
|
| 197 |
captioner = get_image_captioner()
|
|
|
|
| 198 |
with st.spinner("Figuring out what's in your picture..."):
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
# Story and audio section
|
| 203 |
with st.container():
|
| 204 |
-
st.markdown("<div class='section-header'>
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
}
|
| 105 |
.stButton>button {
|
| 106 |
background-color: #ffcccb;
|
| 107 |
+
color: #000000;
|
| 108 |
border-radius: 10px;
|
| 109 |
border: 2px solid #ff9999;
|
| 110 |
font-size: 18px;
|
|
|
|
| 114 |
}
|
| 115 |
.stButton>button:hover {
|
| 116 |
background-color: #ff9999;
|
| 117 |
+
color: #ffffff;
|
| 118 |
transform: scale(1.05);
|
| 119 |
}
|
| 120 |
.stFileUploader {
|
| 121 |
+
background-color: #ffb300;
|
| 122 |
+
border: 2px dashed #ff8c00;
|
| 123 |
border-radius: 10px;
|
| 124 |
padding: 10px;
|
| 125 |
}
|
|
|
|
| 126 |
.stFileUploader div[role="button"] {
|
| 127 |
+
background-color: #f0f0f0;
|
| 128 |
border-radius: 10px;
|
| 129 |
padding: 10px;
|
| 130 |
}
|
| 131 |
.stFileUploader div[role="button"] > div {
|
| 132 |
+
color: #000000 !important;
|
| 133 |
font-size: 16px;
|
| 134 |
}
|
|
|
|
| 135 |
.stFileUploader button {
|
| 136 |
+
background-color: #ffca28 !important;
|
| 137 |
+
color: #000000 !important;
|
| 138 |
border-radius: 8px !important;
|
| 139 |
+
border: 2px solid #ffb300 !important;
|
| 140 |
padding: 5px 15px !important;
|
| 141 |
font-weight: bold !important;
|
| 142 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
|
| 143 |
}
|
| 144 |
.stFileUploader button:hover {
|
| 145 |
+
background-color: #ff8c00 !important;
|
| 146 |
+
color: #000000 !important;
|
| 147 |
}
|
| 148 |
.stImage {
|
| 149 |
border: 3px solid #81c784;
|
|
|
|
| 157 |
text-align: center;
|
| 158 |
font-size: 24px;
|
| 159 |
font-weight: bold;
|
| 160 |
+
color: #000000;
|
| 161 |
margin-bottom: 10px;
|
| 162 |
}
|
| 163 |
.caption-box, .story-box {
|
|
|
|
| 166 |
border-radius: 10px;
|
| 167 |
border: 2px solid #d4e157;
|
| 168 |
margin-bottom: 20px;
|
| 169 |
+
color: #000000;
|
| 170 |
}
|
| 171 |
.caption-box b, .story-box b {
|
| 172 |
+
color: #000000;
|
| 173 |
+
}
|
| 174 |
+
.stProgress > div > div {
|
| 175 |
+
background-color: #81c784;
|
| 176 |
}
|
| 177 |
</style>
|
| 178 |
""", unsafe_allow_html=True)
|
|
|
|
| 195 |
|
| 196 |
# Caption section
|
| 197 |
with st.container():
|
| 198 |
+
st.markdown("<div class='section-header'>2οΈβ£ What's in the Picture? π§</div>", unsafe_allow_html=True)
|
| 199 |
captioner = get_image_captioner()
|
| 200 |
+
progress_bar = st.progress(0)
|
| 201 |
with st.spinner("Figuring out what's in your picture..."):
|
| 202 |
+
for i in range(100):
|
| 203 |
+
progress_bar.progress(i + 1)
|
| 204 |
+
if i == 99:
|
| 205 |
+
caption = part1_image_to_text(pil_img, captioner)
|
| 206 |
+
progress_bar.empty()
|
| 207 |
+
st.markdown(f"<div class='caption-box'><b>Picture Description:</b><br>{caption}</div>", unsafe_allow_html=True)
|
| 208 |
|
| 209 |
# Story and audio section
|
| 210 |
with st.container():
|
| 211 |
+
st.markdown("<div class='section-header'>3οΈβ£ Your Story and Audio! π΅</div>", unsafe_allow_html=True)
|
| 212 |
+
# Story
|
| 213 |
+
story_pipe = get_story_pipe()
|
| 214 |
+
progress_bar = st.progress(0)
|
| 215 |
+
with st.spinner("Writing a super cool story..."):
|
| 216 |
+
for i in range(100):
|
| 217 |
+
progress_bar.progress(i + 1)
|
| 218 |
+
if i == 99:
|
| 219 |
+
story = part2_text_to_story(caption, story_pipe)
|
| 220 |
+
progress_bar.empty()
|
| 221 |
+
st.markdown(f"<div class='story-box'><b>Your Cool Story! π</b><br>{story}</div>", unsafe_allow_html=True)
|
| 222 |
|
| 223 |
+
# TTS
|
| 224 |
+
tts_pipe = get_tts_pipe()
|
| 225 |
+
progress_bar = st.progress(0)
|
| 226 |
+
with st.spinner("Turning your story into sound..."):
|
| 227 |
+
for i in range(100):
|
| 228 |
+
progress_bar.progress(i + 1)
|
| 229 |
+
if i == 99:
|
| 230 |
+
audio_bytes = part3_text_to_speech_bytes(story, tts_pipe)
|
| 231 |
+
progress_bar.empty()
|
| 232 |
+
st.audio(audio_bytes, format="audio/wav")
|