forouzanfallah commited on
Commit
6032b28
·
verified ·
1 Parent(s): 453f64d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -14
app.py CHANGED
@@ -446,26 +446,40 @@ def submit_next_image(
446
  # gr.update(),
447
  # )
448
 
449
- left_after = user_left_count(progress[uid]["seen"], samples)
450
- target = user_target_count(samples)
 
451
 
452
- if left_after == 0:
453
  status = (
454
  f"Saved! You’ve completed all {target} images. 🎉 "
455
  f"Click **Exit** to close this session."
456
  )
457
  return (
458
- updated_seen, -1,
459
- None, None, None, None, None, # Return None to avoid image load errors
460
- gr.update(value="Target reached! Processing..."),
461
- gr.update(value=""),
462
- 5, 5, 5, 5, 5,
463
- gr.update(value=None)
464
- )
465
-
466
- idx_next = pick_next_index(progress[uid]["seen"], samples)
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  if idx_next == -1:
468
- return (updated_seen, -1, None, None, None, None, None, "No more images.", "", 5, 5, 5, 5, 5, None)
469
  # Fallback if no images left
470
  # return (
471
  # progress[uid]["seen"], -1,
@@ -493,7 +507,7 @@ def submit_next_image(
493
  gr.update(value=""),
494
  gr.update(value=""),
495
  5, 5, 5, 5, 5,
496
- gr.update(value=None)
497
  )
498
  # return (
499
  # progress[uid]["seen"], idx_next,
 
446
  # gr.update(),
447
  # )
448
 
449
+ # left_after = user_left_count(progress[uid]["seen"], samples)
450
+ # target = user_target_count(samples)
451
+ updated_seen = progress[uid]["seen"]
452
 
453
+ if len(updated_seen) >= TARGET_PER_PERSON:
454
  status = (
455
  f"Saved! You’ve completed all {target} images. 🎉 "
456
  f"Click **Exit** to close this session."
457
  )
458
  return (
459
+ updated_seen, -1,
460
+ None, None, None, None, None, # No more images to load
461
+ gr.update(value="Target reached!"), # Status
462
+ gr.update(value=""), # Clear notes
463
+ 5, 5, 5, 5, 5 # Reset sliders
464
+ )
465
+
466
+ # if left_after == 0:
467
+ # status = (
468
+ # f"Saved! You’ve completed all {target} images. 🎉 "
469
+ # f"Click **Exit** to close this session."
470
+ # )
471
+ # return (
472
+ # updated_seen, -1,
473
+ # None, None, None, None, None, # Return None to avoid image load errors
474
+ # gr.update(value="Target reached! Processing..."),
475
+ # gr.update(value=""),
476
+ # 5, 5, 5, 5, 5,
477
+ # gr.update(value=None)
478
+ # )
479
+
480
+ idx_next = pick_next_index(updated_seen, samples)
481
  if idx_next == -1:
482
+ return (updated_seen, -1, None, None, None, None, None, "No more images.", "", 5, 5, 5, 5, 5)
483
  # Fallback if no images left
484
  # return (
485
  # progress[uid]["seen"], -1,
 
507
  gr.update(value=""),
508
  gr.update(value=""),
509
  5, 5, 5, 5, 5,
510
+
511
  )
512
  # return (
513
  # progress[uid]["seen"], idx_next,