Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,35 +16,15 @@ def set_custom_style():
|
|
| 16 |
.stApp {
|
| 17 |
max-width: 800px;
|
| 18 |
margin: 0 auto;
|
| 19 |
-
|
| 20 |
-
padding: 2rem;
|
| 21 |
-
border-radius: 10px;
|
| 22 |
}
|
| 23 |
.title {
|
| 24 |
color: #1e3a8a;
|
| 25 |
font-size: 2.5rem;
|
| 26 |
font-weight: bold;
|
| 27 |
-
margin-bottom:
|
| 28 |
text-align: center;
|
| 29 |
}
|
| 30 |
-
.upload-section {
|
| 31 |
-
background-color: white;
|
| 32 |
-
padding: 2rem;
|
| 33 |
-
border-radius: 10px;
|
| 34 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 35 |
-
}
|
| 36 |
-
.caption-section {
|
| 37 |
-
background-color: white;
|
| 38 |
-
padding: 2rem;
|
| 39 |
-
border-radius: 10px;
|
| 40 |
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
| 41 |
-
margin-top: 2rem;
|
| 42 |
-
}
|
| 43 |
-
.caption-text {
|
| 44 |
-
font-size: 1.2rem;
|
| 45 |
-
font-style: italic;
|
| 46 |
-
color: #4a5568;
|
| 47 |
-
}
|
| 48 |
.stButton>button {
|
| 49 |
background-color: #3b82f6;
|
| 50 |
color: white;
|
|
@@ -57,6 +37,24 @@ def set_custom_style():
|
|
| 57 |
.stButton>button:hover {
|
| 58 |
background-color: #2563eb;
|
| 59 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
</style>
|
| 61 |
""", unsafe_allow_html=True)
|
| 62 |
|
|
@@ -65,9 +63,7 @@ def main():
|
|
| 65 |
|
| 66 |
st.markdown('<h1 class="title">Image Captioning App</h1>', unsafe_allow_html=True)
|
| 67 |
|
| 68 |
-
st.markdown('<div class="upload-section">', unsafe_allow_html=True)
|
| 69 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
| 70 |
-
st.markdown('</div>', unsafe_allow_html=True)
|
| 71 |
|
| 72 |
if uploaded_file is not None:
|
| 73 |
try:
|
|
@@ -78,7 +74,7 @@ def main():
|
|
| 78 |
with st.spinner('Generating caption...'):
|
| 79 |
try:
|
| 80 |
caption = generate_caption(image)
|
| 81 |
-
st.markdown('<div class="caption-
|
| 82 |
st.markdown("### Generated Caption:")
|
| 83 |
st.markdown(f'<p class="caption-text">{caption}</p>', unsafe_allow_html=True)
|
| 84 |
st.markdown('</div>', unsafe_allow_html=True)
|
|
|
|
| 16 |
.stApp {
|
| 17 |
max-width: 800px;
|
| 18 |
margin: 0 auto;
|
| 19 |
+
padding: 1rem;
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
.title {
|
| 22 |
color: #1e3a8a;
|
| 23 |
font-size: 2.5rem;
|
| 24 |
font-weight: bold;
|
| 25 |
+
margin-bottom: 1rem;
|
| 26 |
text-align: center;
|
| 27 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
.stButton>button {
|
| 29 |
background-color: #3b82f6;
|
| 30 |
color: white;
|
|
|
|
| 37 |
.stButton>button:hover {
|
| 38 |
background-color: #2563eb;
|
| 39 |
}
|
| 40 |
+
.caption-container {
|
| 41 |
+
background-color: #f3f4f6;
|
| 42 |
+
padding: 1rem;
|
| 43 |
+
border-radius: 5px;
|
| 44 |
+
margin-top: 1rem;
|
| 45 |
+
}
|
| 46 |
+
.caption-text {
|
| 47 |
+
font-size: 1.2rem;
|
| 48 |
+
font-style: italic;
|
| 49 |
+
color: #4a5568;
|
| 50 |
+
}
|
| 51 |
+
.stAlert {
|
| 52 |
+
background-color: #fee2e2;
|
| 53 |
+
color: #991b1b;
|
| 54 |
+
padding: 0.5rem;
|
| 55 |
+
border-radius: 5px;
|
| 56 |
+
margin-top: 1rem;
|
| 57 |
+
}
|
| 58 |
</style>
|
| 59 |
""", unsafe_allow_html=True)
|
| 60 |
|
|
|
|
| 63 |
|
| 64 |
st.markdown('<h1 class="title">Image Captioning App</h1>', unsafe_allow_html=True)
|
| 65 |
|
|
|
|
| 66 |
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
|
|
|
| 67 |
|
| 68 |
if uploaded_file is not None:
|
| 69 |
try:
|
|
|
|
| 74 |
with st.spinner('Generating caption...'):
|
| 75 |
try:
|
| 76 |
caption = generate_caption(image)
|
| 77 |
+
st.markdown('<div class="caption-container">', unsafe_allow_html=True)
|
| 78 |
st.markdown("### Generated Caption:")
|
| 79 |
st.markdown(f'<p class="caption-text">{caption}</p>', unsafe_allow_html=True)
|
| 80 |
st.markdown('</div>', unsafe_allow_html=True)
|