question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] rich.prograss.track() Prograss Bar without color

See original GitHub issue

Describe the bug I want use rich colorful terminal progress bar to monitor training processing by PyTorch module. You can see the code here

  for i, (image, mask) in track(enumerate(train_loader), description=f"train_{epoch}", total=len(train_loader)):
      image, mask = image.to(device), mask.to(device)

      predict_image = net(image)
      train_loss = loss_function(predict_image, mask)
      loss_list = np.append(loss_list, train_loss.item())

      opt.zero_grad()
      train_loss.backward()
      opt.step()

      train_preds = torch.cat((train_preds, predict_image.cpu().detach()), 0)
      train_truths = torch.cat((train_truths, mask.cpu().detach()), 0)


      _image = image[0]
      _mask = mask[0]
      _pred_image = predict_image[0]

      _pred_image[_pred_image >= threshold] = 1
      _pred_image[_pred_image < threshold] = 0

      vaisual_image = torch.stack([_image, _mask, _pred_image], dim=0)
      torchvision.utils.save_image(vaisual_image, os.path.join(monitor_path, 'train', f'{i}.png'))

But the bar is without color and in a high flicker.

Platform

Win and Powershell

β”‚ β”‚ β”‚ color_system = β€˜truecolor’ β”‚ β”‚ encoding = β€˜utf-8’ β”‚ β”‚ file = <_io.TextIOWrapper name=β€˜<stdout>’ mode=β€˜w’ encoding=β€˜utf-8’> β”‚ β”‚ height = 30 β”‚ β”‚ is_alt_screen = False β”‚ β”‚ is_dumb_terminal = False β”‚ β”‚ is_interactive = True β”‚ β”‚ is_jupyter = False β”‚ β”‚ is_terminal = True β”‚ β”‚ legacy_windows = False β”‚ β”‚ no_color = False β”‚ β”‚ options = ConsoleOptions( β”‚ β”‚ size=ConsoleDimensions(width=120, height=30), β”‚ β”‚ legacy_windows=False, β”‚ β”‚ min_width=1, β”‚ β”‚ max_width=120, β”‚ β”‚ is_terminal=True, β”‚ β”‚ encoding=β€˜utf-8’, β”‚ β”‚ max_height=30, β”‚ β”‚ justify=None, β”‚ β”‚ overflow=None, β”‚ β”‚ no_wrap=False, β”‚ β”‚ highlight=None, β”‚ β”‚ markup=None, β”‚ β”‚ height=None β”‚ β”‚ ) β”‚ β”‚ quiet = False β”‚ β”‚ record = False β”‚ β”‚ safe_box = True β”‚ β”‚ size = ConsoleDimensions(width=120, height=30) β”‚ β”‚ soft_wrap = False β”‚ β”‚ stderr = False β”‚ β”‚ style = None β”‚ β”‚ tab_size = 8 β”‚ β”‚ width = 120

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Msameim181commented, Jul 24, 2022

I think this comment solves this issue. The result is good on VSCode (or -insider). But on the windows console, as the same as before, and NO improvement has been achieved.

1reaction
Msameim181commented, May 20, 2022

Same problem here, I checked out with rich.progress.track() and in another example, I used the β€œLive” progress bar like your example in here, It works perfectly. BUT when I combine it with Pytorch, It goes wrong.

Here is some screenshot: Good (This should look like): image

Bad (What I got): image

I Couldn’t figure out why, Please help.

Read more comments on GitHub >

github_iconTop Results From Across the Web

rich.progress.track() terminal prograss bar without color - YouTube
In the last, I ctrl+c to stop the python script. That's why the 'Exception' shows up. It has no relation with rich module....
Read more >
Progress Display β€” Rich 12.6.0 documentation
Rich progress display supports multiple tasks, each with a bar and progress information. You can use this to track concurrent tasks where the...
Read more >
Python Progress Bar - Stack Overflow
I have no idea. Right now I am not printing anything while the function is being executed, however a progress bar would be...
Read more >
[Question] Manually updatable progress bars #399 - GitHub
It looks to me like I could use something like the multi progress bar example, but looking at the code it was not...
Read more >
how to add a progress bar in python rich Code Example
update the bar. 14. sys.stdout.write("-"). 15. sys.stdout.flush(). 16. ​. 17. sys.stdout.write("]\n") # this ends the progress bar.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found