A nested progress with plotting options for fastai
Maintained. Last release 7 months ago, commits in 6 of the last 26 weeks. Weaker on contributor spread.
pip install fastprogressfastprogress
A fast and simple progress bar for Jupyter Notebook and console.
Install
To install simply use
pip install fastprogress
Usage
Example 1
Here is a simple example. Each bar takes an iterator as a main argument, and we can specify the second bar is nested with the first by adding the argument parent=mb. We can then:
- add a comment in the first bar by changing the value of
mb.main_bar.comment - add a comment in the second bar by changing the value of
mb.child.comment - write a line between the two bars with
mb.write('message')
from fastprogress.fastprogress import *
from time import sleep
for i in (mb:=master_bar(range(10))):
for j in mb.progress(range(100)):
sleep(0.01)
mb.child.comment = f'second bar stat'
mb.main_bar.comment = f'first bar stat'
mb.write(f'Finished loop {i}.')
Example 2
To add a graph that get plots as the training goes, just use the command mb.update_graphs. It will create the figure on its first use. Arguments are:
graphs: a list of graphs to be plotted (each of the form[x,y])x_bounds: the min and max values of the x axis (ifNone, it will those given by the graphs)y_bounds: the min and max values of the y axis (ifNone, it will those given by the graphs)
Note that it's best to specify x_bounds and y_bounds, otherwise the box will change as the loop progresses.
Additionally, we can give the label of each graph via the command mb.names (should have as many elements as the graphs argument).
import numpy as np
for i in mb:=master_bar(range(10), names=['cos', 'sin']):
for j in mb.progress(range(100)):
if j%10 == 0:
k = 100 * i + j
x = np.arange(0, 2*k*np.pi/1000, 0.01)
y1, y2 = np.cos(x), np.sin(x)
graphs = [[x,y1], [x,y2]]
x_bounds = [0, 2*np.pi]
y_bounds = [-1,1]
mb.update_graph(graphs, x_bounds, y_bounds)
mb.child.comment = f'second bar stat'
mb.main_bar.comment = f'first bar stat'
mb.write(f'Finished loop {i}.')


