Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -51,23 +51,23 @@ def generate_caption(image):
|
|
| 51 |
result_text = f"Detected objects: {tags}\nCaption: {caption}"
|
| 52 |
return result_text, gallery
|
| 53 |
|
| 54 |
-
# Custom CSS
|
| 55 |
custom_css = """
|
| 56 |
#app-title {
|
| 57 |
text-align: center;
|
| 58 |
font-size: 36px;
|
| 59 |
-
color: #4DB8FF; /*
|
| 60 |
font-weight: bold;
|
| 61 |
}
|
| 62 |
|
| 63 |
#instructions {
|
| 64 |
text-align: center;
|
| 65 |
font-size: 18px;
|
| 66 |
-
color
|
| 67 |
}
|
| 68 |
|
| 69 |
#generate-btn {
|
| 70 |
-
background: linear-gradient(90deg, #1E90FF, #32CD32); /* lake blue
|
| 71 |
color: white;
|
| 72 |
font-weight: bold;
|
| 73 |
border: none;
|
|
@@ -81,22 +81,22 @@ custom_css = """
|
|
| 81 |
"""
|
| 82 |
|
| 83 |
with gr.Blocks(css=custom_css) as iface:
|
| 84 |
-
# Centered header and
|
| 85 |
gr.HTML('<h1 id="app-title">🖼️ Image Captioning with Object Detection</h1>')
|
| 86 |
gr.HTML(
|
| 87 |
'<p id="instructions">👋 Welcome! This app detects objects in your image and generates a descriptive caption.<br>'
|
| 88 |
'🪄 <b>How to use:</b><br>'
|
| 89 |
'1️⃣ Upload an image below<br>'
|
| 90 |
'2️⃣ Click <b>⭐ Generate Caption</b> to start analysis<br>'
|
| 91 |
-
'3️⃣ View caption and detected
|
| 92 |
'💡 The last <b>15 results</b> will be saved for your review!</p>'
|
| 93 |
)
|
| 94 |
|
| 95 |
-
#
|
| 96 |
image_input = gr.Image(type="pil", label="Upload Image")
|
| 97 |
generate_btn = gr.Button("⭐ Generate Caption", elem_id="generate-btn")
|
| 98 |
|
| 99 |
-
#
|
| 100 |
caption_output = gr.Textbox(label="📝 Caption and Detected Objects", lines=3, interactive=False)
|
| 101 |
|
| 102 |
# History gallery
|
|
|
|
| 51 |
result_text = f"Detected objects: {tags}\nCaption: {caption}"
|
| 52 |
return result_text, gallery
|
| 53 |
|
| 54 |
+
# Custom CSS styles
|
| 55 |
custom_css = """
|
| 56 |
#app-title {
|
| 57 |
text-align: center;
|
| 58 |
font-size: 36px;
|
| 59 |
+
color: #4DB8FF; /* Light blue header */
|
| 60 |
font-weight: bold;
|
| 61 |
}
|
| 62 |
|
| 63 |
#instructions {
|
| 64 |
text-align: center;
|
| 65 |
font-size: 18px;
|
| 66 |
+
/* Removed custom color for better theme contrast */
|
| 67 |
}
|
| 68 |
|
| 69 |
#generate-btn {
|
| 70 |
+
background: linear-gradient(90deg, #1E90FF, #32CD32); /* lake blue → light green */
|
| 71 |
color: white;
|
| 72 |
font-weight: bold;
|
| 73 |
border: none;
|
|
|
|
| 81 |
"""
|
| 82 |
|
| 83 |
with gr.Blocks(css=custom_css) as iface:
|
| 84 |
+
# Centered header and description
|
| 85 |
gr.HTML('<h1 id="app-title">🖼️ Image Captioning with Object Detection</h1>')
|
| 86 |
gr.HTML(
|
| 87 |
'<p id="instructions">👋 Welcome! This app detects objects in your image and generates a descriptive caption.<br>'
|
| 88 |
'🪄 <b>How to use:</b><br>'
|
| 89 |
'1️⃣ Upload an image below<br>'
|
| 90 |
'2️⃣ Click <b>⭐ Generate Caption</b> to start analysis<br>'
|
| 91 |
+
'3️⃣ View caption and detected objects instantly below.<br>'
|
| 92 |
'💡 The last <b>15 results</b> will be saved for your review!</p>'
|
| 93 |
)
|
| 94 |
|
| 95 |
+
# Upload image and Generate button directly below
|
| 96 |
image_input = gr.Image(type="pil", label="Upload Image")
|
| 97 |
generate_btn = gr.Button("⭐ Generate Caption", elem_id="generate-btn")
|
| 98 |
|
| 99 |
+
# Result output
|
| 100 |
caption_output = gr.Textbox(label="📝 Caption and Detected Objects", lines=3, interactive=False)
|
| 101 |
|
| 102 |
# History gallery
|