Shortcuts

Utils

ProgressBar

If you want to apply a method to a list of items and track the progress, track_progress is a good choice. It will display a progress bar to tell the progress and ETA.

import mmcv

def func(item):
    # do something
    pass

tasks = [item_1, item_2, ..., item_n]

mmcv.track_progress(func, tasks)

The output is like the following.

progress

There is another method track_parallel_progress, which wraps multiprocessing and progress visualization.

mmcv.track_parallel_progress(func, tasks, 8)  # 8 workers

progress

If you want to iterate or enumerate a list of items and track the progress, track_iter_progress is a good choice. It will display a progress bar to tell the progress and ETA.

import mmcv

tasks = [item_1, item_2, ..., item_n]

for task in mmcv.track_iter_progress(tasks):
    # do something like print
    print(task)

for i, task in enumerate(mmcv.track_iter_progress(tasks)):
    # do something like print
    print(i)
    print(task)

Timer

It is convenient to compute the runtime of a code block with Timer.

import time

with mmcv.Timer():
    # simulate some code block
    time.sleep(1)

or try with since_start() and since_last_check(). This former can return the runtime since the timer starts and the latter will return the time since the last time checked.

timer = mmcv.Timer()
# code block 1 here
print(timer.since_start())
# code block 2 here
print(timer.since_last_check())
print(timer.since_start())
Read the Docs v: v1.4.5
Versions
master
latest
v1.5.2_a
v1.5.1
v1.5.0
v1.4.8
v1.4.7
v1.4.6
v1.4.5
v1.4.4
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.18
v1.3.17
v1.3.16
v1.3.15
v1.3.14
v1.3.13
v1.3.12
v1.3.11
v1.3.10
v1.3.9
v1.3.8
v1.3.7
v1.3.6
v1.3.5
v1.3.4
v1.3.3
v1.3.2
v1.3.1
v1.3.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.