MCPcopy Create free account
hub / github.com/modelscope/modelscope / update

Method update

modelscope/preprocessors/cv/util.py:50–76  ·  view source on GitHub ↗
(self, num_tasks=1)

Source from the content-addressed store, hash-verified

48 self.timer = Timer()
49
50 def update(self, num_tasks=1):
51 assert num_tasks > 0
52 self.completed += num_tasks
53 elapsed = self.timer.since_start()
54 if elapsed > 0:
55 fps = self.completed / elapsed
56 else:
57 fps = float('inf')
58 if self.task_num > 0:
59 percentage = self.completed / float(self.task_num)
60 eta = int(elapsed * (1 - percentage) / percentage + 0.5)
61 msg = f'\r[{{}}] {self.completed}/{self.task_num}, ' \
62 f'{fps:.1f} task/s, elapsed: {int(elapsed + 0.5)}s, ' \
63 f'ETA: {eta:5}s'
64
65 bar_width = min(self.bar_width,
66 int(self.terminal_width - len(msg)) + 2,
67 int(self.terminal_width * 0.6))
68 bar_width = max(2, bar_width)
69 mark_width = int(bar_width * percentage)
70 bar_chars = '>' * mark_width + ' ' * (bar_width - mark_width)
71 self.file.write(msg.format(bar_chars))
72 else:
73 self.file.write(
74 f'completed: {self.completed}, elapsed: {int(elapsed + 0.5)}s,'
75 f' {fps:.1f} tasks/s')
76 self.file.flush()
77
78
79def track_progress(func, tasks, bar_width=50, file=sys.stdout, **kwargs):

Callers 9

track_progressFunction · 0.95
__call__Method · 0.45
from_pretrainedMethod · 0.45
encodeMethod · 0.45
_encodeMethod · 0.45
_encodeMethod · 0.45
_encodeMethod · 0.45
_encodeMethod · 0.45
run_mmseqs2Function · 0.45

Calls 2

since_startMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected