mupparajuk31 commited on
Commit
db11e84
·
verified ·
1 Parent(s): beaaa12

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +88 -86
templates/index.html CHANGED
@@ -179,37 +179,44 @@
179
  background-color: #25d366;
180
  border-radius: 4px;
181
  }
182
- .output-image-container{
 
183
  background-color: #e4e6eb; /* Light gray color for bot messages */
184
  color: #333;
185
  border-top-left-radius: 0;
186
  align-self: flex-start;
187
  display: flex;
188
  justify-content: space-between;
 
189
  }
190
- .output-image-container img{
191
- width: 50%;
 
192
  height: auto;
193
  }
194
- .sample{
195
- width: 10px;
196
- position: absolute;
 
 
 
 
 
 
 
197
  }
198
- .download-button {
199
- margin-top: 10px;
200
- padding: 10px 15px;
201
- background-color: #007bff;
202
- color: white;
203
- border: none;
204
- border-radius: 5px;
205
- cursor: pointer;
206
- font-size: 14px;
207
- }
208
 
209
- .download-button:hover {
210
- background-color: #0056b3;
 
 
 
 
 
 
 
 
211
  }
212
-
213
  </style>
214
  </head>
215
  <body>
@@ -221,13 +228,12 @@
221
  {% if image_url %}
222
  <div class="chat-bubble user">Image uploaded successfully!</div>
223
  <div class="output-image-container">
224
- <img src="{{ image_url }}" class="uploaded-image" alt="Uploaded Image">
225
- <a href="{{ image_url }}" download>
226
- <button class="download-button">Download</button>
227
- </a>
228
- <div class="sample"></div>
229
- <img src="{{ input_image_url }}" class="uploaded-image" alt="Uploaded Image">
230
- </div>
231
 
232
  <div class="chat-bubble bot">
233
  Would you like to generate a caption or ask a question about the image?
@@ -247,19 +253,19 @@
247
  {% endif %}
248
 
249
  {% if similar_images %}
250
- <div class="similar-images-container">
251
- <div class="chat-bubble bot">Here are some similar images:</div>
252
- <div id="similar-images-list" class="row">
253
- {% for img_url in similar_images %}
254
- <div class="col-md-3 mb-3 similar-image" style="display: {{ 'block' if loop.index <= 4 else 'none' }};">
255
- <img src="{{ img_url }}" class="img-fluid" alt="Similar Image">
 
 
 
 
256
  </div>
257
- {% endfor %}
258
- </div>
259
- <button id="toggle-button" class="btn btn-primary mt-3">Show More</button>
260
- </div>
261
- {% endif %}
262
- </div>
263
 
264
  <div class="chat-footer">
265
  {% if not image_url %}
@@ -278,7 +284,6 @@
278
  <button type="submit" class="btn btn-primary">Upload Image</button>
279
  </form>
280
  </div>
281
-
282
  {% else %}
283
  <div class="message-container">
284
  <form action="{{ url_for('process_image') }}" method="POST">
@@ -301,69 +306,66 @@
301
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
302
  <script>
303
  $(document).ready(function () {
304
- // Hide all forms initially
305
  $('#caption-form').hide();
306
  $('#vqa-form').hide();
307
-
308
  // Show caption form when "Generate Caption" button is clicked
309
  $('#generate-caption').click(function() {
310
  $('#caption-form').show();
311
  $('#vqa-form').hide();
312
  });
313
-
314
  // Show VQA form when "Ask a Question" button is clicked
315
  $('#ask-question').click(function() {
316
  $('#vqa-form').show();
317
  $('#caption-form').hide();
318
  });
319
-
320
  // Hide the "Please enter a question" alert once an answer is displayed
321
  {% if answer %}
322
  $('.alert-info').hide();
323
  {% endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  });
325
- $(document).ready(function () {
326
- // Event listener for the file input change
327
- $('#file').on('change', function () {
328
- var file = this.files[0];
329
- if (file) {
330
- // Display the file name
331
- $('#file-name').text("Selected file: " + file.name);
332
-
333
- // Create an object URL for the image and display it as a preview
334
- var reader = new FileReader();
335
- reader.onload = function (e) {
336
- $('#preview-img').attr('src', e.target.result).show();
337
- };
338
- reader.readAsDataURL(file);
339
- } else {
340
- $('#file-name').text(""); // Reset file name if no file is selected
341
- $('#preview-img').hide(); // Hide preview if no file is selected
342
- }
343
- });
344
- });
345
-
346
-
347
- $(document).ready(function () {
348
- const similarImages = $('.similar-image'); // All similar images
349
- const toggleButton = $('#toggle-button');
350
- let isExpanded = false; // Track state of visibility
351
-
352
- // Click event for "Show More" / "Show Less"
353
- toggleButton.on('click', function () {
354
- if (isExpanded) {
355
- // Collapse to show only the first 4 images
356
- similarImages.slice(4).hide();
357
- toggleButton.text('Show More');
358
- } else {
359
- // Expand to show all images
360
- similarImages.show();
361
- toggleButton.text('Show Less');
362
- }
363
- isExpanded = !isExpanded; // Toggle state
364
- });
365
- });
366
-
367
  </script>
 
368
  </body>
369
- </html>
 
179
  background-color: #25d366;
180
  border-radius: 4px;
181
  }
182
+
183
+ .output-image-container {
184
  background-color: #e4e6eb; /* Light gray color for bot messages */
185
  color: #333;
186
  border-top-left-radius: 0;
187
  align-self: flex-start;
188
  display: flex;
189
  justify-content: space-between;
190
+ gap: 10px;
191
  }
192
+
193
+ .output-image-container img {
194
+ width: 48%; /* Allow images to be side-by-side */
195
  height: auto;
196
  }
197
+
198
+ .download-button {
199
+ margin-top: 10px;
200
+ padding: 10px 15px;
201
+ background-color: #02ca59;
202
+ color: white;
203
+ border: none;
204
+ border-radius: 5px;
205
+ cursor: pointer;
206
+ font-size: 14px;
207
  }
 
 
 
 
 
 
 
 
 
 
208
 
209
+ .download-button:hover {
210
+ background-color: #00b34e;
211
+ }
212
+ #preview-img {
213
+ max-width: 300px; /* Adjust the max-width to limit the size */
214
+ max-height: 300px; /* Optional: add max height to limit the height */
215
+ display: none;
216
+ margin-bottom: 3px;
217
+ border-radius: 20px;
218
+ object-fit: contain; /* Ensures the image maintains its aspect ratio */
219
  }
 
220
  </style>
221
  </head>
222
  <body>
 
228
  {% if image_url %}
229
  <div class="chat-bubble user">Image uploaded successfully!</div>
230
  <div class="output-image-container">
231
+ <img src="{{ image_url }}" class="uploaded-image" alt="Uploaded Image">
232
+ <img src="{{ input_image_url }}" class="uploaded-image" alt="Enhanced Image">
233
+ </div>
234
+ <a href="{{ input_image_url }}" download>
235
+ <button class="download-button">Download Enhanced Image</button>
236
+ </a>
 
237
 
238
  <div class="chat-bubble bot">
239
  Would you like to generate a caption or ask a question about the image?
 
253
  {% endif %}
254
 
255
  {% if similar_images %}
256
+ <div class="similar-images-container">
257
+ <div class="chat-bubble bot">Here are some similar images:</div>
258
+ <div id="similar-images-list" class="row">
259
+ {% for img_url in similar_images %}
260
+ <div class="col-md-3 mb-3 similar-image" style="display: {{ 'block' if loop.index <= 4 else 'none' }};">
261
+ <img src="{{ img_url }}" class="img-fluid" alt="Similar Image">
262
+ </div>
263
+ {% endfor %}
264
+ </div>
265
+ <button id="toggle-button" class="btn btn-primary mt-3">Show More</button>
266
  </div>
267
+ {% endif %}
268
+ </div>
 
 
 
 
269
 
270
  <div class="chat-footer">
271
  {% if not image_url %}
 
284
  <button type="submit" class="btn btn-primary">Upload Image</button>
285
  </form>
286
  </div>
 
287
  {% else %}
288
  <div class="message-container">
289
  <form action="{{ url_for('process_image') }}" method="POST">
 
306
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
307
  <script>
308
  $(document).ready(function () {
309
+ // Initially hide the forms for Caption and VQA
310
  $('#caption-form').hide();
311
  $('#vqa-form').hide();
312
+
313
  // Show caption form when "Generate Caption" button is clicked
314
  $('#generate-caption').click(function() {
315
  $('#caption-form').show();
316
  $('#vqa-form').hide();
317
  });
318
+
319
  // Show VQA form when "Ask a Question" button is clicked
320
  $('#ask-question').click(function() {
321
  $('#vqa-form').show();
322
  $('#caption-form').hide();
323
  });
324
+
325
  // Hide the "Please enter a question" alert once an answer is displayed
326
  {% if answer %}
327
  $('.alert-info').hide();
328
  {% endif %}
329
+
330
+ // File input change listener for image preview and file name
331
+ $('#file').on('change', function () {
332
+ var file = this.files[0];
333
+ if (file) {
334
+ // Display the file name
335
+ $('#file-name').text("Selected file: " + file.name);
336
+
337
+ // Create an object URL for the image and display it as a preview
338
+ var reader = new FileReader();
339
+ reader.onload = function (e) {
340
+ $('#preview-img').attr('src', e.target.result).show();
341
+ };
342
+ reader.readAsDataURL(file);
343
+ } else {
344
+ $('#file-name').text(""); // Reset file name if no file is selected
345
+ $('#preview-img').hide(); // Hide preview if no file is selected
346
+ }
347
+ });
348
+
349
+ // Similar images functionality: Toggle between "Show More" and "Show Less"
350
+ const similarImages = $('.similar-image'); // All similar images
351
+ const toggleButton = $('#toggle-button');
352
+ let isExpanded = false; // Track state of visibility
353
+
354
+ // Click event for "Show More" / "Show Less"
355
+ toggleButton.on('click', function () {
356
+ if (isExpanded) {
357
+ // Collapse to show only the first 4 images
358
+ similarImages.slice(4).hide();
359
+ toggleButton.text('Show More');
360
+ } else {
361
+ // Expand to show all images
362
+ similarImages.show();
363
+ toggleButton.text('Show Less');
364
+ }
365
+ isExpanded = !isExpanded; // Toggle state
366
+ });
367
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
368
  </script>
369
+
370
  </body>
371
+ </html>