{"id":13717302,"url":"https://github.com/AnswerDotAI/fastprogress","last_synced_at":"2025-11-07T04:30:36.051Z","repository":{"id":33073868,"uuid":"145069949","full_name":"AnswerDotAI/fastprogress","owner":"AnswerDotAI","description":"Simple and flexible progress bar for Jupyter Notebook and console","archived":false,"fork":false,"pushed_at":"2024-08-20T15:56:03.000Z","size":13061,"stargazers_count":1089,"open_issues_count":22,"forks_count":104,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-02-16T23:30:08.654Z","etag":null,"topics":["developer-tools","jupyter-notebook","plots","python"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AnswerDotAI.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-17T04:01:23.000Z","updated_at":"2025-02-16T12:59:23.000Z","dependencies_parsed_at":"2024-11-15T04:49:05.990Z","dependency_job_id":"4e9844ed-0094-4f12-b417-378a46073a21","html_url":"https://github.com/AnswerDotAI/fastprogress","commit_stats":{"total_commits":188,"total_committers":25,"mean_commits":7.52,"dds":0.7180851063829787,"last_synced_commit":"3264b4da7edd7b0061b0ace0d44e8fabc29652f3"},"previous_names":["answerdotai/fastprogress","fastai/fastprogress"],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Ffastprogress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Ffastprogress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Ffastprogress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AnswerDotAI%2Ffastprogress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AnswerDotAI","download_url":"https://codeload.github.com/AnswerDotAI/fastprogress/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239517098,"owners_count":19652073,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-tools","jupyter-notebook","plots","python"],"created_at":"2024-08-03T00:01:20.481Z","updated_at":"2025-11-07T04:30:35.980Z","avatar_url":"https://github.com/AnswerDotAI.png","language":"Jupyter Notebook","readme":"# fastprogress\n\nA fast and simple progress bar for Jupyter Notebook and console. Created by Sylvain Gugger for fast.ai.\n\n\u003cimg src=\"https://github.com/fastai/fastprogress/raw/master/images/cifar_train.gif\" width=\"600\"\u003e\n\n## Install\n\nTo install simply use\n```\npip install fastprogress\n```\nor:\n```\nconda install -c fastai fastprogress\n```\nNote that this requires python 3.6 or later.\n\n## Usage\n\n### Example 1\n\nHere 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:\n- add a comment in the first bar by changing the value of `mb.main_bar.comment`\n- add a comment in the second bar by changing the value of `mb.child.comment`\n- write a line between the two bars with `mb.write('message')`\n\n``` python\nfrom fastprogress.fastprogress import master_bar, progress_bar\nfrom time import sleep\nmb = master_bar(range(10))\nfor i in mb:\n    for j in progress_bar(range(100), parent=mb):\n        sleep(0.01)\n        mb.child.comment = f'second bar stat'\n    mb.main_bar.comment = f'first bar stat'\n    mb.write(f'Finished loop {i}.')\n    #mb.update_graph(graphs, x_bounds, y_bounds)\n```\n\n\u003cimg src=\"https://github.com/fastai/fastprogress/raw/master/images/pb_basic.gif\" width=\"600\"\u003e\n\n### Example 2\n\nTo 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:\n- `graphs`: a list of graphs to be plotted (each of the form `[x,y]`)\n- `x_bounds`: the min and max values of the x axis (if `None`, it will those given by the graphs)\n- `y_bounds`: the min and max values of the y axis (if `None`, it will those given by the graphs)\n\nNote that it's best to specify `x_bounds` and `y_bounds`, otherwise the box will change as the loop progresses.\n\nAdditionally, we can give the label of each graph via the command `mb.names` (should have as many elements as the graphs argument).\n\n``` python\nimport numpy as np\nmb = master_bar(range(10))\nmb.names = ['cos', 'sin']\nfor i in mb:\n    for j in progress_bar(range(100), parent=mb):\n        if j%10 == 0:\n            k = 100 * i + j\n            x = np.arange(0, 2*k*np.pi/1000, 0.01)\n            y1, y2 = np.cos(x), np.sin(x)\n            graphs = [[x,y1], [x,y2]]\n            x_bounds = [0, 2*np.pi]\n            y_bounds = [-1,1]\n            mb.update_graph(graphs, x_bounds, y_bounds)\n            mb.child.comment = f'second bar stat'\n    mb.main_bar.comment = f'first bar stat'\n    mb.write(f'Finished loop {i}.')\n```\n\n\u003cimg src=\"https://github.com/fastai/fastprogress/raw/master/images/pb_cos.gif\" width=\"600\"\u003e\n\nHere is the rendering in console:\n\n\u003cimg src=\"https://github.com/fastai/fastprogress/raw/master/images/pb_console.gif\" width=\"800\"\u003e\n\nIf the script using this is executed with a redirect to a file, only the results of the `.write` method will be printed in that file.\n\n### Example 3\n\nHere is an example that a typical machine learning training loop can use. It also demonstrates how to set `y_bounds` dynamically.\n\n```\ndef plot_loss_update(epoch, epochs, mb, train_loss, valid_loss):\n    \"\"\" dynamically print the loss plot during the training/validation loop.\n        expects epoch to start from 1.\n    \"\"\"\n    x = range(1, epoch+1)\n    y = np.concatenate((train_loss, valid_loss))\n    graphs = [[x,train_loss], [x,valid_loss]]\n    x_margin = 0.2\n    y_margin = 0.05\n    x_bounds = [1-x_margin, epochs+x_margin]\n    y_bounds = [np.min(y)-y_margin, np.max(y)+y_margin]\n\n    mb.update_graph(graphs, x_bounds, y_bounds)\n```\n\nAnd here is an emulation of a training loop that uses this function:\n\n```\nfrom fastprogress.fastprogress import master_bar, progress_bar\nfrom time import sleep\nimport numpy as np\nimport random\n\nepochs = 5\nmb = master_bar(range(1, epochs+1))\n# optional: graph legend: if not set, the default is 'train'/'valid'\n# mb.names = ['first', 'second']\ntrain_loss, valid_loss = [], []\nfor epoch in mb:\n    # emulate train sub-loop\n    for batch in progress_bar(range(2), parent=mb): sleep(0.2)\n    train_loss.append(0.5 - 0.06 * epoch + random.uniform(0, 0.04))\n\n    # emulate validation sub-loop\n    for batch in progress_bar(range(2), parent=mb): sleep(0.2)\n    valid_loss.append(0.5 - 0.03 * epoch + random.uniform(0, 0.04))\n\n    plot_loss_update(epoch, epochs, mb, train_loss, valid_loss)\n```\n\nAnd the output:\n\n\u003cimg src=\"https://github.com/fastai/fastprogress/raw/master/images/pb_graph.gif\" alt=\"Output\"\u003e\n\n----\n\nCopyright 2017 onwards, fast.ai. Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. A copy of the License is provided in the LICENSE file in this repository.\n","funding_links":[],"categories":["Python","Jupyter Notebook"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAnswerDotAI%2Ffastprogress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAnswerDotAI%2Ffastprogress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAnswerDotAI%2Ffastprogress/lists"}