Hi all, I’m having some trouble with the .tta method. After loading in the dataloader exactly like I did for training:
dls=ImageDataLoaders.from_folder('/content/', train='train', valid='val',
item_tfms=Resize(460), batch_tfms=aug_transforms(flip_vert=True, max_rotate=45.0, size=224))
and loading the saved model as:
learn=load_learner(model_path)
I’ve verified that the learner works and is loaded correctly (e.g. learn.predict(path_to_img) works).
learn.tta(dl=dls)
Errors out giving
epoch train_loss valid_loss accuracy time
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-68-bf2efe30447d> in <module>()
----> 1 learn.tta(dl=dls)
13 frames
/usr/local/lib/python3.6/dist-packages/fastai/learner.py in tta(self, ds_idx, dl, n, item_tfms, batch_tfms, beta, use_max)
558 if item_tfms is not None or batch_tfms is not None: dl = dl.new(after_item=item_tfms, after_batch=batch_tfms)
559 try:
--> 560 self(_before_epoch)
561 with dl.dataset.set_split_idx(0), self.no_mbar():
562 if hasattr(self,'progress'): self.progress.mbar = master_bar(list(range(n)))
/usr/local/lib/python3.6/dist-packages/fastai/learner.py in __call__(self, event_name)
131 def ordered_cbs(self, event): return [cb for cb in sort_by_run(self.cbs) if hasattr(cb, event)]
132
--> 133 def __call__(self, event_name): L(event_name).map(self._call_one)
134
135 def _call_one(self, event_name):
/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in map(self, f, *args, **kwargs)
381 else f.format if isinstance(f,str)
382 else f.__getitem__)
--> 383 return self._new(map(g, self))
384
385 def filter(self, f, negate=False, **kwargs):
/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in _new(self, items, *args, **kwargs)
331 @property
332 def _xtra(self): return None
--> 333 def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
334 def __getitem__(self, idx): return self._get(idx) if is_indexer(idx) else L(self._get(idx), use_list=None)
335 def copy(self): return self._new(self.items.copy())
/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
45 return x
46
---> 47 res = super().__call__(*((x,) + args), **kwargs)
48 res._newchk = 0
49 return res
/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __init__(self, items, use_list, match, *rest)
322 if items is None: items = []
323 if (use_list is not None) or not _is_array(items):
--> 324 items = list(items) if use_list else _listify(items)
325 if match is not None:
326 if is_coll(match): match = len(match)
/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in _listify(o)
258 if isinstance(o, list): return o
259 if isinstance(o, str) or _is_array(o): return [o]
--> 260 if is_iter(o): return list(o)
261 return [o]
262
/usr/local/lib/python3.6/dist-packages/fastcore/foundation.py in __call__(self, *args, **kwargs)
224 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
225 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 226 return self.fn(*fargs, **kwargs)
227
228 # Cell
/usr/local/lib/python3.6/dist-packages/fastai/learner.py in _call_one(self, event_name)
135 def _call_one(self, event_name):
136 assert hasattr(event, event_name), event_name
--> 137 [cb(event_name) for cb in sort_by_run(self.cbs)]
138
139 def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)
/usr/local/lib/python3.6/dist-packages/fastai/learner.py in <listcomp>(.0)
135 def _call_one(self, event_name):
136 assert hasattr(event, event_name), event_name
--> 137 [cb(event_name) for cb in sort_by_run(self.cbs)]
138
139 def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)
/usr/local/lib/python3.6/dist-packages/fastai/callback/core.py in __call__(self, event_name)
42 (self.run_valid and not getattr(self, 'training', False)))
43 res = None
---> 44 if self.run and _run: res = getattr(self, event_name, noop)()
45 if event_name=='after_fit': self.run=True #Reset self.run to True at each end of fit
46 return res
/usr/local/lib/python3.6/dist-packages/fastai/callback/progress.py in before_epoch(self)
21
22 def before_epoch(self):
---> 23 if getattr(self, 'mbar', False): self.mbar.update(self.epoch)
24
25 def before_train(self): self._launch_pbar()
/usr/local/lib/python3.6/dist-packages/fastprogress/fastprogress.py in update(self, val)
92 yield o
93
---> 94 def update(self, val): self.main_bar.update(val)
95
96 # Cell
/usr/local/lib/python3.6/dist-packages/fastprogress/fastprogress.py in update(self, val)
55 self.pred_t,self.last_v,self.wait_for = 0,0,1
56 self.update_bar(0)
---> 57 elif val <= self.first_its or val >= self.last_v + self.wait_for or val >= self.total:
58 cur_t = time.time()
59 avg_t = (cur_t - self.start_t) / val
AttributeError: 'NBProgressBar' object has no attribute 'wait_for'
Any idea what I’m doing wrong and how to fix it?
Just in case it’s helpful: I’m running on Colab using the course setup:
!pip install -Uqq fastbook
import fastbook
fastbook.setup_book()
!pip install utils
from utils import *