Hey I am a bit new to productionising models. So when I exported my cnn_learner from my dev machine to the production machine, read it using load_learner, and then called predict I got this strange error. Any help would be appreciated. I am using the latest v2.
I get the feeling it has something to do with the transforms but anyway here’s the traceback:
File “/Users/ribhu/Desktop/MoodMaestro/PoC test/sample.py”, line 78, in
st.write(learn_dn.predict(img_array)[0])
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-
packages/fastai/learner.py”, line 248, in predict
inp,preds,_,dec_preds = self.get_preds(dl=dl, with_input=True, with_decoded=True)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-
packages/fastai/learner.py”, line 235, in get_preds
self._do_epoch_validate(dl=dl)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/learner.py”, line 188, in _do_epoch_validate
with torch.no_grad(): self._with_events(self.all_batches, ‘validate’, CancelValidException)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/learner.py”, line 155, in with_events
try: self(f’before{event_type}') ;f()
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/learner.py”, line 161, in all_batches
for o in enumerate(self.dl): self.one_batch(*o)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/data/load.py”, line 102, in iter
for b in _loadersself.fake_l.num_workers==0:
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/torch/utils/data/dataloader.py”, line 363, in next
data = self._next_data()
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/torch/utils/data/dataloader.py”, line 403, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py”, line 34, in fetch
data = next(self.dataset_iter)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/data/load.py”, line 111, in create_batches
yield from map(self.do_batch, self.chunkify(res))
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastcore/utils.py”, line 375, in chunked
res = list(itertools.islice(it, chunk_sz))
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/data/load.py”, line 124, in do_item
try: return self.after_item(self.create_item(s))
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/data/load.py”, line 130, in create_item
def create_item(self, s): return next(self.it) if s is None else self.dataset[s]
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/data/core.py”, line 314, in getitem
res = tuple([tl[it] for tl in self.tls])
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/data/core.py”, line 314, in
res = tuple([tl[it] for tl in self.tls])
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/data/core.py”, line 280, in getitem
return self._after_item(res) if is_indexer(idx) else res.map(self._after_item)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastai/data/core.py”, line 242, in _after_item
def _after_item(self, o): return self.tfms(o)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastcore/transform.py”, line 198, in call
def call(self, o): return compose_tfms(o, tfms=self.fs, split_idx=self.split_idx)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastcore/transform.py”, line 150, in compose_tfms
x = f(x, **kwargs)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastcore/transform.py”, line 73, in call
def call(self, x, **kwargs): return self._call(‘encodes’, x, **kwargs)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastcore/transform.py”, line 83, in _call
return self._do_call(getattr(self, fn), x, **kwargs)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastcore/transform.py”, line 89, in _do_call
return retain_type(f(x, **kwargs), x, ret)
File “/Users/ribhu/anaconda3/envs/moodmaestro/lib/python3.8/site-packages/fastcore/dispatch.py”, line 113, in call
elif self.owner is not None: f = MethodType(f, self.owner)