JS6969 commited on
Commit
427a18c
·
verified ·
1 Parent(s): fe7adce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -766,7 +766,12 @@ with gr.Blocks(css=BASE_CSS, title="ForgeCaptions") as demo:
766
  value="Manual (step)", label="Batch mode"
767
  )
768
  chunk_size = gr.Slider(1, 50, value=10, step=1, label="Chunk size")
769
- gpu_budget = gr.Slider(20, 110, value=55, step=5, label="Max seconds per GPU call")
 
 
 
 
 
770
 
771
  # Logo controls
772
  logo_auto = gr.Checkbox(value=settings.get("logo_auto", True),
@@ -966,6 +971,7 @@ with gr.Blocks(css=BASE_CSS, title="ForgeCaptions") as demo:
966
  t, p, m = _tpms()
967
  files = files or []
968
 
 
969
  if mode == "Manual (step)" and files:
970
  chunks = _split_chunks(files, int(csize))
971
  batch = chunks[0]
@@ -979,6 +985,7 @@ with gr.Blocks(css=BASE_CSS, title="ForgeCaptions") as demo:
979
  prog = f"Batch progress: {done}/{total} processed in this step • Remaining overall: {len(remaining)}"
980
  return new_rows, gal, tbl, stamp, remaining, panel_vis, gr.update(value=msg), gr.update(value=prog)
981
 
 
982
  new_rows, gal, tbl, stamp, leftover, done, total = run_batch(
983
  files, rows or [], instr, t, p, m, int(ms), float(budget_s)
984
  )
@@ -989,19 +996,21 @@ with gr.Blocks(css=BASE_CSS, title="ForgeCaptions") as demo:
989
 
990
  run_button.click(
991
  _run_click,
992
- inputs=[input_files, rows_state, instruction_preview, max_side, chunk_mode, chunk_size, gpu_budget],
993
  outputs=[rows_state, gallery, table, autosave_md, remaining_state, step_panel, step_msg, progress_md]
994
  )
995
 
996
  def _step_next(remain, rows, instr, ms, csize, budget_s):
997
  t, p, m = _tpms()
998
  remain = remain or []
 
 
999
  if not remain:
1000
  return rows, gr.update(value="No files remaining."), gr.update(visible=False), [], [], [], "Saved.", gr.update(value="")
1001
  batch = remain[:int(csize)]
1002
  leftover = remain[int(csize):]
1003
  new_rows, gal, tbl, stamp, leftover_from_batch, done, total = run_batch(
1004
- batch, rows or [], instr, t, p, m, int(ms), float(budget_s)
1005
  )
1006
  leftover = (leftover_from_batch or []) + leftover
1007
  panel_vis = gr.update(visible=bool(leftover))
@@ -1011,7 +1020,7 @@ with gr.Blocks(css=BASE_CSS, title="ForgeCaptions") as demo:
1011
 
1012
  step_next.click(
1013
  _step_next,
1014
- inputs=[remaining_state, rows_state, instruction_preview, max_side, chunk_size, gpu_budget],
1015
  outputs=[rows_state, step_msg, step_panel, remaining_state, gallery, table, autosave_md, progress_md]
1016
  )
1017
 
 
766
  value="Manual (step)", label="Batch mode"
767
  )
768
  chunk_size = gr.Slider(1, 50, value=10, step=1, label="Chunk size")
769
+ gpu_budget = gr.Slider(20, 120, value=55, step=5, label="Max seconds per GPU call")
770
+ no_time_limit = gr.Checkbox(
771
+ value=True,
772
+ label="No time limit (may time out on Zero GPU)"
773
+ )
774
+
775
 
776
  # Logo controls
777
  logo_auto = gr.Checkbox(value=settings.get("logo_auto", True),
 
971
  t, p, m = _tpms()
972
  files = files or []
973
 
974
+ #Manual (Step)
975
  if mode == "Manual (step)" and files:
976
  chunks = _split_chunks(files, int(csize))
977
  batch = chunks[0]
 
985
  prog = f"Batch progress: {done}/{total} processed in this step • Remaining overall: {len(remaining)}"
986
  return new_rows, gal, tbl, stamp, remaining, panel_vis, gr.update(value=msg), gr.update(value=prog)
987
 
988
+ #Auto/all-at-once
989
  new_rows, gal, tbl, stamp, leftover, done, total = run_batch(
990
  files, rows or [], instr, t, p, m, int(ms), float(budget_s)
991
  )
 
996
 
997
  run_button.click(
998
  _run_click,
999
+ inputs=[input_files, rows_state, instruction_preview, max_side, chunk_mode, chunk_size, gpu_budget, no_time_limit],
1000
  outputs=[rows_state, gallery, table, autosave_md, remaining_state, step_panel, step_msg, progress_md]
1001
  )
1002
 
1003
  def _step_next(remain, rows, instr, ms, csize, budget_s):
1004
  t, p, m = _tpms()
1005
  remain = remain or []
1006
+ budget = None if no_limit else float(budget_s)
1007
+
1008
  if not remain:
1009
  return rows, gr.update(value="No files remaining."), gr.update(visible=False), [], [], [], "Saved.", gr.update(value="")
1010
  batch = remain[:int(csize)]
1011
  leftover = remain[int(csize):]
1012
  new_rows, gal, tbl, stamp, leftover_from_batch, done, total = run_batch(
1013
+ batch, rows or [], instr, t, p, m, int(ms), budget
1014
  )
1015
  leftover = (leftover_from_batch or []) + leftover
1016
  panel_vis = gr.update(visible=bool(leftover))
 
1020
 
1021
  step_next.click(
1022
  _step_next,
1023
+ inputs=[remaining_state, rows_state, instruction_preview, max_side, chunk_size, gpu_budget, no_time_limit],
1024
  outputs=[rows_state, step_msg, step_panel, remaining_state, gallery, table, autosave_md, progress_md]
1025
  )
1026