def silent_console(silent:bool=True): "Turn off console progress bar output." fastprogress.fastprogress.NO_BAR = silent mbar, pbar = force_console_behavior() cls_list = [fastprogress.fastprogress, basic_train, basic_data, dataclasses.dataclass, text, text.data, core] for c in cls_list: c.master_bar, c.progress_bar = mbar,pbar
def hide_fastai_progress_bar(): """Hide fastai progress bar""" fastprogress.fastprogress.NO_BAR = True fastprogress.fastprogress.WRITER_FN = str master_bar, progress_bar = force_console_behavior() fastai.basic_train.master_bar, fastai.basic_train.progress_bar = ( master_bar, progress_bar, )
def __enter__(self): #silence progress bar fastprogress.fastprogress.NO_BAR = True fastai.basic_train.master_bar, fastai.basic_train.progress_bar = force_console_behavior( ) self.orig_callback_fns = copy(self.learn.callback_fns) rec_name = [ x for x in self.learn.callback_fns if hasattr(x, 'func') and x.func == Recorder ] if len(rec_name): rec_idx = self.learn.callback_fns.index(rec_name[0]) self.learn.callback_fns[rec_idx] = partial( Recorder, add_time=True, silent=True) #silence recorder return self.learn
def silent_console(silent: bool = True): "Turn off console progress bar output." import fastai2.torch_core, fastai2.text.learner, fastai2.text.core, fastai2.callback.progress, fastai2.data.external fastprogress.fastprogress.NO_BAR = silent mbar, pbar = force_console_behavior() cls_list = [ fastprogress.fastprogress, fastai2.torch_core, fastai2.text.learner, fastai2.text.core, fastai2.callback.progress, fastai2.data.external, ] for c in cls_list: c.master_bar, c.progress_bar = mbar, pbar
import numpy as np import torch from torch.utils.data import Dataset, TensorDataset, DataLoader import fastai from fastai.vision import Image # For fastai pbar work in notebooks in vscode and pycharm from fastprogress.fastprogress import force_console_behavior master_bar, progress_bar = force_console_behavior() fastai.basic_train.master_bar, fastai.basic_train.progress_bar = master_bar, progress_bar class ImageArrayDS(Dataset): def __init__(self, images, labels, tfms=None): self.images = torch.FloatTensor(images) self.labels = torch.LongTensor(labels) self.tfms = tfms def __getitem__(self, idx): image = Image(self.images[idx]) if self.tfms is not None: image = image.apply_tfms(self.tfms) return image, self.labels[idx] def __len__(self): return len(self.images) class Inferencer: def __init__(self, model, batch_size=8192):
def __enter__(self): if self.show: return # silence progress bar fastprogress.fastprogress.NO_BAR = True fastai.basic_train.master_bar, fastai.basic_train.progress_bar = force_console_behavior()