Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -289,15 +289,14 @@ class DatasetCollectionApp:
|
|
| 289 |
)
|
| 290 |
|
| 291 |
def create_validation_interface(self):
|
| 292 |
-
"""Create validation interface with
|
| 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
|
| 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]
|
|
@@ -310,23 +309,23 @@ class DatasetCollectionApp:
|
|
| 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=
|
| 315 |
style='padding: 8px 12px; background: #228be6; color: white;
|
| 316 |
-
border: none; border-radius: 5px; cursor: pointer;
|
| 317 |
-
|
| 318 |
</button>
|
| 319 |
-
<button
|
| 320 |
-
onclick="document.querySelectorAll('[data-dog=
|
| 321 |
style='padding: 8px 12px; background: #868e96; color: white;
|
| 322 |
-
border: none; border-radius: 5px; cursor: pointer;
|
| 323 |
-
|
| 324 |
</button>
|
| 325 |
-
<button
|
| 326 |
-
onclick="if(confirm('Delete all images for Dog #{temp_id}?'))
|
| 327 |
style='padding: 8px 12px; background: #fa5252; color: white;
|
| 328 |
-
border: none; border-radius: 5px; cursor: pointer;
|
| 329 |
-
|
| 330 |
</button>
|
| 331 |
</div>
|
| 332 |
</div>
|
|
@@ -340,18 +339,16 @@ class DatasetCollectionApp:
|
|
| 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 |
-
|
|
|
|
|
|
|
| 346 |
style='position: absolute; top: 8px; left: 8px;
|
| 347 |
-
width:
|
| 348 |
-
cursor: pointer;
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 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;'>
|
|
@@ -365,10 +362,6 @@ class DatasetCollectionApp:
|
|
| 365 |
</div>
|
| 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
|
| 374 |
|
|
|
|
| 289 |
)
|
| 290 |
|
| 291 |
def create_validation_interface(self):
|
| 292 |
+
"""Create validation interface with inline onclick handlers"""
|
| 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 from saving</p>"
|
|
|
|
| 300 |
|
| 301 |
for temp_id in sorted(self.temp_session.keys()):
|
| 302 |
dog_data = self.temp_session[temp_id]
|
|
|
|
| 309 |
align-items: center; margin-bottom: 15px;'>
|
| 310 |
<h3 style='margin: 0;'>Temp Dog #{temp_id} - {len(images)} images</h3>
|
| 311 |
<div style='display: flex; gap: 10px;'>
|
| 312 |
+
<button type='button'
|
| 313 |
+
onclick="var cbs=document.querySelectorAll('input[data-dog=dog{temp_id}]'); for(var i=0;i<cbs.length;i++){{cbs[i].checked=true;}}"
|
| 314 |
style='padding: 8px 12px; background: #228be6; color: white;
|
| 315 |
+
border: none; border-radius: 5px; cursor: pointer;'>
|
| 316 |
+
Select All
|
| 317 |
</button>
|
| 318 |
+
<button type='button'
|
| 319 |
+
onclick="var cbs=document.querySelectorAll('input[data-dog=dog{temp_id}]'); for(var i=0;i<cbs.length;i++){{cbs[i].checked=false;}}"
|
| 320 |
style='padding: 8px 12px; background: #868e96; color: white;
|
| 321 |
+
border: none; border-radius: 5px; cursor: pointer;'>
|
| 322 |
+
Deselect All
|
| 323 |
</button>
|
| 324 |
+
<button type='button'
|
| 325 |
+
onclick="if(confirm('Delete all images for Dog #{temp_id}?')){{var cbs=document.querySelectorAll('input[data-dog=dog{temp_id}]'); for(var i=0;i<cbs.length;i++){{cbs[i].checked=false;}}}}"
|
| 326 |
style='padding: 8px 12px; background: #fa5252; color: white;
|
| 327 |
+
border: none; border-radius: 5px; cursor: pointer;'>
|
| 328 |
+
Delete This Dog
|
| 329 |
</button>
|
| 330 |
</div>
|
| 331 |
</div>
|
|
|
|
| 339 |
html += f"""
|
| 340 |
<div style='position: relative;'>
|
| 341 |
<input type='checkbox'
|
|
|
|
| 342 |
data-dog='dog{temp_id}'
|
| 343 |
+
id='dog{temp_id}_img{idx}'
|
| 344 |
+
name='dog{temp_id}_img{idx}'
|
| 345 |
+
checked='checked'
|
| 346 |
style='position: absolute; top: 8px; left: 8px;
|
| 347 |
+
width: 20px; height: 20px; z-index: 10;
|
| 348 |
+
cursor: pointer;'>
|
| 349 |
+
<img src='data:image/jpeg;base64,{img_base64}'
|
| 350 |
+
style='width: 100%; aspect-ratio: 1; object-fit: cover;
|
| 351 |
+
border-radius: 5px; border: 2px solid #dee2e6;'>
|
|
|
|
|
|
|
|
|
|
| 352 |
<div style='position: absolute; bottom: 5px; right: 5px;
|
| 353 |
background: rgba(0,0,0,0.7); color: white;
|
| 354 |
padding: 2px 6px; border-radius: 3px; font-size: 10px;'>
|
|
|
|
| 362 |
</div>
|
| 363 |
"""
|
| 364 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
html += "</div>"
|
| 366 |
return html
|
| 367 |
|