Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -289,14 +289,15 @@ class DatasetCollectionApp:
|
|
| 289 |
)
|
| 290 |
|
| 291 |
def create_validation_interface(self):
|
| 292 |
-
"""Create
|
| 293 |
|
| 294 |
if not self.temp_session:
|
| 295 |
return "<p>No temporary session to validate</p>"
|
| 296 |
|
| 297 |
html = "<div style='padding: 20px;'>"
|
| 298 |
-
html += "<h2 style='text-align:center;'>Validation -
|
| 299 |
-
html += "<p style='text-align:center; color:#666;'>
|
|
|
|
| 300 |
|
| 301 |
for temp_id in sorted(self.temp_session.keys()):
|
| 302 |
dog_data = self.temp_session[temp_id]
|
|
@@ -305,7 +306,30 @@ class DatasetCollectionApp:
|
|
| 305 |
html += f"""
|
| 306 |
<div style='border: 2px solid #495057; border-radius: 10px;
|
| 307 |
padding: 15px; margin: 20px 0; background: #f8f9fa;'>
|
| 308 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
<div style='display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;'>
|
| 310 |
"""
|
| 311 |
|
|
@@ -315,9 +339,19 @@ class DatasetCollectionApp:
|
|
| 315 |
|
| 316 |
html += f"""
|
| 317 |
<div style='position: relative;'>
|
| 318 |
-
<
|
| 319 |
-
|
| 320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
<div style='position: absolute; bottom: 5px; right: 5px;
|
| 322 |
background: rgba(0,0,0,0.7); color: white;
|
| 323 |
padding: 2px 6px; border-radius: 3px; font-size: 10px;'>
|
|
@@ -332,8 +366,8 @@ class DatasetCollectionApp:
|
|
| 332 |
"""
|
| 333 |
|
| 334 |
html += "<p style='text-align:center; color:#868e96; margin-top: 30px;'>"
|
| 335 |
-
html += "
|
| 336 |
-
html += "
|
| 337 |
html += "</p>"
|
| 338 |
html += "</div>"
|
| 339 |
return html
|
|
|
|
| 289 |
)
|
| 290 |
|
| 291 |
def create_validation_interface(self):
|
| 292 |
+
"""Create validation interface with selection controls"""
|
| 293 |
|
| 294 |
if not self.temp_session:
|
| 295 |
return "<p>No temporary session to validate</p>"
|
| 296 |
|
| 297 |
html = "<div style='padding: 20px;'>"
|
| 298 |
+
html += "<h2 style='text-align:center;'>Validation - Select Images to Keep</h2>"
|
| 299 |
+
html += "<p style='text-align:center; color:#666;'>Uncheck images to exclude them from saving</p>"
|
| 300 |
+
html += "<p style='text-align:center; color:#e03131; font-size: 12px;'>⚠️ Note: Buttons may not work in all environments. If not working, just review visually and save all.</p>"
|
| 301 |
|
| 302 |
for temp_id in sorted(self.temp_session.keys()):
|
| 303 |
dog_data = self.temp_session[temp_id]
|
|
|
|
| 306 |
html += f"""
|
| 307 |
<div style='border: 2px solid #495057; border-radius: 10px;
|
| 308 |
padding: 15px; margin: 20px 0; background: #f8f9fa;'>
|
| 309 |
+
<div style='display: flex; justify-content: space-between;
|
| 310 |
+
align-items: center; margin-bottom: 15px;'>
|
| 311 |
+
<h3 style='margin: 0;'>Temp Dog #{temp_id} - {len(images)} images</h3>
|
| 312 |
+
<div style='display: flex; gap: 10px;'>
|
| 313 |
+
<button
|
| 314 |
+
onclick="document.querySelectorAll('[data-dog=\\'dog{temp_id}\\']').forEach(cb => cb.checked = true); return false;"
|
| 315 |
+
style='padding: 8px 12px; background: #228be6; color: white;
|
| 316 |
+
border: none; border-radius: 5px; cursor: pointer; font-size: 13px;'>
|
| 317 |
+
✓ Select All
|
| 318 |
+
</button>
|
| 319 |
+
<button
|
| 320 |
+
onclick="document.querySelectorAll('[data-dog=\\'dog{temp_id}\\']').forEach(cb => cb.checked = false); return false;"
|
| 321 |
+
style='padding: 8px 12px; background: #868e96; color: white;
|
| 322 |
+
border: none; border-radius: 5px; cursor: pointer; font-size: 13px;'>
|
| 323 |
+
✗ Deselect All
|
| 324 |
+
</button>
|
| 325 |
+
<button
|
| 326 |
+
onclick="if(confirm('Delete all images for Dog #{temp_id}?')) {{ document.querySelectorAll('[data-dog=\\'dog{temp_id}\\']').forEach(cb => cb.checked = false); }} return false;"
|
| 327 |
+
style='padding: 8px 12px; background: #fa5252; color: white;
|
| 328 |
+
border: none; border-radius: 5px; cursor: pointer; font-size: 13px;'>
|
| 329 |
+
🗑 Delete Dog
|
| 330 |
+
</button>
|
| 331 |
+
</div>
|
| 332 |
+
</div>
|
| 333 |
<div style='display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px;'>
|
| 334 |
"""
|
| 335 |
|
|
|
|
| 339 |
|
| 340 |
html += f"""
|
| 341 |
<div style='position: relative;'>
|
| 342 |
+
<input type='checkbox'
|
| 343 |
+
id='dog{temp_id}_img{idx}'
|
| 344 |
+
data-dog='dog{temp_id}'
|
| 345 |
+
checked
|
| 346 |
+
style='position: absolute; top: 8px; left: 8px;
|
| 347 |
+
width: 24px; height: 24px; z-index: 10;
|
| 348 |
+
cursor: pointer; accent-color: #228be6;'
|
| 349 |
+
onclick='event.stopPropagation();'>
|
| 350 |
+
<label for='dog{temp_id}_img{idx}' style='cursor: pointer; display: block;'>
|
| 351 |
+
<img src='data:image/jpeg;base64,{img_base64}'
|
| 352 |
+
style='width: 100%; aspect-ratio: 1; object-fit: cover;
|
| 353 |
+
border-radius: 5px; border: 2px solid #dee2e6;'>
|
| 354 |
+
</label>
|
| 355 |
<div style='position: absolute; bottom: 5px; right: 5px;
|
| 356 |
background: rgba(0,0,0,0.7); color: white;
|
| 357 |
padding: 2px 6px; border-radius: 3px; font-size: 10px;'>
|
|
|
|
| 366 |
"""
|
| 367 |
|
| 368 |
html += "<p style='text-align:center; color:#868e96; margin-top: 30px;'>"
|
| 369 |
+
html += "Review images and uncheck any you want to exclude.<br>"
|
| 370 |
+
html += "Click 'Save to Database' to save checked images."
|
| 371 |
html += "</p>"
|
| 372 |
html += "</div>"
|
| 373 |
return html
|