fastai / fastai_dev

fast.ai early development experiments
Apache License 2.0
638 stars 350 forks source link

Fix multi categorize #246

Closed radekosmulski closed 4 years ago

radekosmulski commented 4 years ago

This fixes the issue but unfortunately breaks show called through show_batch

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-16-4bc6a3c4e872> in <module>
----> 1 dbch.show_batch(max_n=9)

~/work/fastai_dev/dev/local/data/core.py in show_batch(self, b, max_n, ctxs, **kwargs)
     82         "Show `b` (defaults to `one_batch`), a list of lists of pipeline outputs (i.e. output of a `DataLoader`)"
     83         if b is None: b = self.one_batch()
---> 84         show_batch(*self._pre_show_batch(b, max_n=max_n, **kwargs), ctxs=ctxs, max_n=max_n, **kwargs)
     85 
     86     def show_results(self, b, out, max_n=10, ctxs=None, **kwargs):

~/work/fastai_dev/dev/local/dispatch.py in __call__(self, *args, **kwargs)
     95         if not f: return args[0]
     96         if self.inst is not None: f = types.MethodType(f, self.inst)
---> 97         return f(*args, **kwargs)
     98 
     99     def __get__(self, inst, owner):

~/work/fastai_dev/dev/local/vision/core.py in show_batch(x, y, its, ctxs, max_n, rows, cols, figsize, **kwargs)
    245 def show_batch(x:TensorImage, y, its, ctxs=None, max_n=10, rows=None, cols=None, figsize=None, **kwargs):
    246     if ctxs is None: ctxs = _get_grid(min(len(its), max_n), rows=rows, cols=cols, figsize=figsize)
--> 247     ctxs = default_show_batch(x, y, its, ctxs=ctxs, max_n=max_n, **kwargs)
    248     return ctxs
    249 

~/work/fastai_dev/dev/local/data/core.py in default_show_batch(x, y, its, ctxs, max_n, **kwargs)
     14     if ctxs is None: ctxs = Inf.nones
     15     for i in range(1 if y is None else 2):
---> 16         ctxs = [b.show(ctx=c, **kwargs) for b,c,_ in zip(its.itemgot(i),ctxs,range(max_n))]
     17     return ctxs
     18 

~/work/fastai_dev/dev/local/data/core.py in <listcomp>(.0)
     14     if ctxs is None: ctxs = Inf.nones
     15     for i in range(1 if y is None else 2):
---> 16         ctxs = [b.show(ctx=c, **kwargs) for b,c,_ in zip(its.itemgot(i),ctxs,range(max_n))]
     17     return ctxs
     18 

~/work/fastai_dev/dev/local/core.py in __getattr__(self, k)
    204     def __getattr__(self,k):
    205         if k not in ('_xtra',self._default) and (self._xtra is None or k in self._xtra): return getattr(getattr(self,self._default), k)
--> 206         raise AttributeError(k)
    207     def __dir__(self): return custom_dir(self, self._xtra)
    208     def __setstate__(self,data): self.__dict__.update(data)

AttributeError: show
review-notebook-app[bot] commented 4 years ago

Check out this pull request on  ReviewNB

You'll be able to see Jupyter notebook diff and discuss changes. Powered by ReviewNB.

sgugger commented 4 years ago

Fixed another way :)