shared_total_tqdm.py 993 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import tqdm
  2. from modules import shared
  3. class TotalTQDM:
  4. def __init__(self):
  5. self._tqdm = None
  6. def reset(self):
  7. self._tqdm = tqdm.tqdm(
  8. desc="Total progress",
  9. total=shared.state.job_count * shared.state.sampling_steps,
  10. position=1,
  11. file=shared.progress_print_out
  12. )
  13. def update(self):
  14. if not shared.opts.multiple_tqdm or shared.cmd_opts.disable_console_progressbars:
  15. return
  16. if self._tqdm is None:
  17. self.reset()
  18. self._tqdm.update()
  19. def updateTotal(self, new_total):
  20. if not shared.opts.multiple_tqdm or shared.cmd_opts.disable_console_progressbars:
  21. return
  22. if self._tqdm is None:
  23. self.reset()
  24. self._tqdm.total = new_total
  25. def clear(self):
  26. if self._tqdm is not None:
  27. self._tqdm.refresh()
  28. self._tqdm.close()
  29. self._tqdm = None