forouzanfallah commited on
Commit
f76dc8c
·
verified ·
1 Parent(s): 34563fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -30
app.py CHANGED
@@ -436,15 +436,16 @@ def submit_next_image(
436
  s1, s2, s3, s4, s5,
437
  q1_notes
438
  )
439
- except gr.Error:
440
- return (
441
- user_seen, idx,
442
- gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),
443
- gr.update(),
444
- gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),
445
- gr.update(),
446
- )
447
-
 
448
  left_after = user_left_count(progress[uid]["seen"], samples)
449
  target = user_target_count(samples)
450
 
@@ -454,26 +455,26 @@ def submit_next_image(
454
  f"Click **Exit** to close this session."
455
  )
456
  return (
457
- progress[uid]["seen"], idx,
458
- gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),
459
- gr.update(),
460
- gr.update(value=status),
461
- gr.update(value=""),
462
- gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5),
463
- gr.update(value=None),
464
- )
465
 
466
  idx_next = pick_next_index(progress[uid]["seen"], samples)
467
  if idx_next == -1:
 
468
  # Fallback if no images left
469
- return (
470
- progress[uid]["seen"], -1,
471
- None, None, None, None, None,
472
- gr.update(value="No more images."),
473
- gr.update(value=""),
474
- gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5),
475
- gr.update(value=None),
476
- )
477
 
478
  sample_next = samples[idx_next]
479
 
@@ -483,17 +484,29 @@ def submit_next_image(
483
  # f"Next sample: {sample_next.sample_id}"
484
  # )
485
  return (
486
- progress[uid]["seen"], idx_next,
487
  load_image(sample_next.masked_gt_path),
488
  load_image(sample_next.unmasked_gt_path),
489
  load_image(sample_next.sr_path),
490
  load_image(sample_next.original_path),
491
  load_image(sample_next.image_5_path),
492
- gr.update(value=status),
493
- gr.update(value=""),
494
- gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5),
495
- gr.update(value=None),
496
  )
 
 
 
 
 
 
 
 
 
 
 
 
497
 
498
 
499
  def to_thanks(name: str, user_seen: List[str], samples: List[Sample]):
 
436
  s1, s2, s3, s4, s5,
437
  q1_notes
438
  )
439
+ except gr.Error as e:
440
+ raise e
441
+ # return (
442
+ # user_seen, idx,
443
+ # gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),
444
+ # gr.update(),
445
+ # gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),
446
+ # gr.update(),
447
+ # )
448
+
449
  left_after = user_left_count(progress[uid]["seen"], samples)
450
  target = user_target_count(samples)
451
 
 
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,
472
+ # None, None, None, None, None,
473
+ # gr.update(value="No more images."),
474
+ # gr.update(value=""),
475
+ # gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5),
476
+ # gr.update(value=None),
477
+ # )
478
 
479
  sample_next = samples[idx_next]
480
 
 
484
  # f"Next sample: {sample_next.sample_id}"
485
  # )
486
  return (
487
+ updated_seen, idx_next,
488
  load_image(sample_next.masked_gt_path),
489
  load_image(sample_next.unmasked_gt_path),
490
  load_image(sample_next.sr_path),
491
  load_image(sample_next.original_path),
492
  load_image(sample_next.image_5_path),
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,
500
+ # load_image(sample_next.masked_gt_path),
501
+ # load_image(sample_next.unmasked_gt_path),
502
+ # load_image(sample_next.sr_path),
503
+ # load_image(sample_next.original_path),
504
+ # load_image(sample_next.image_5_path),
505
+ # gr.update(value=status),
506
+ # gr.update(value=""),
507
+ # gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5), gr.update(value=5),
508
+ # gr.update(value=None),
509
+ # )
510
 
511
 
512
  def to_thanks(name: str, user_seen: List[str], samples: List[Sample]):