scmlewis commited on
Commit
1c27e36
·
verified ·
1 Parent(s): 672e664

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
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 for styling header and button
55
  custom_css = """
56
  #app-title {
57
  text-align: center;
58
  font-size: 36px;
59
- color: #4DB8FF; /* light blue */
60
  font-weight: bold;
61
  }
62
 
63
  #instructions {
64
  text-align: center;
65
  font-size: 18px;
66
- color: #333;
67
  }
68
 
69
  #generate-btn {
70
- background: linear-gradient(90deg, #1E90FF, #32CD32); /* lake blue to light green */
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 readable instructions
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 items instantly below.<br>'
92
  '💡 The last <b>15 results</b> will be saved for your review!</p>'
93
  )
94
 
95
- # Image upload and repositioned 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
- # Output: caption + objects
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