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

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

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.

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.