muellerzr / fastinference

A collection of inference modules for fastai2
https://muellerzr.github.io/fastinference
Apache License 2.0
89 stars 16 forks source link

can't import fastinference.onnx #28

Closed hududed closed 3 years ago

hududed commented 3 years ago

Hi @muellerzr

I am running fastinference==0.0.32, fastai==2.1.9 and fastcore==1.3.12.

When I try to import from fastinference.onnx import * to use fastONNX class I get this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-52ff53f82e02> in <module>
----> 1 from fastinference.onnx import *

~/.virtualenvs/challenge/lib/python3.6/site-packages/fastinference/onnx.py in <module>
     18 # Cell
     19 #export
---> 20 from .inference.inference import _decode_loss
     21 
     22 # Cell

~/.virtualenvs/challenge/lib/python3.6/site-packages/fastinference/inference/__init__.py in <module>
----> 1 from .inference import *
      2 from .text import *

~/.virtualenvs/challenge/lib/python3.6/site-packages/fastinference/inference/inference.py in <module>
     52 @patch
     53 def get_preds(self:Learner, ds_idx=1, dl=None, with_input=False, with_decoded=False, with_loss=False, raw=False, act=None,
---> 54                 inner=False, reorder=True, cbs=None, **kwargs):
     55     if dl is None: dl = self.dls[ds_idx].new(shuffled=False, drop_last=False)
     56     if reorder and hasattr(dl, 'get_idxs'):

~/.virtualenvs/challenge/lib/python3.6/site-packages/fastcore/meta.py in _f(f)
    114         to_f = getattr(to_f,'__func__',to_f)
    115         if hasattr(from_f,'__delwrap__'): return f
--> 116         sig = inspect.signature(from_f)
    117         sigd = dict(sig.parameters)
    118         k = sigd.pop('kwargs')

/usr/lib/python3.6/inspect.py in signature(obj, follow_wrapped)
   3063 def signature(obj, *, follow_wrapped=True):
   3064     """Get a signature object for the passed callable."""
-> 3065     return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
   3066 
   3067 

/usr/lib/python3.6/inspect.py in from_callable(cls, obj, follow_wrapped)
   2813         """Constructs Signature for the given callable object."""
   2814         return _signature_from_callable(obj, sigcls=cls,
-> 2815                                         follow_wrapper_chains=follow_wrapped)
   2816 
   2817     @property

/usr/lib/python3.6/inspect.py in _signature_from_callable(obj, follow_wrapper_chains, skip_bound_arg, sigcls)
   2191 
   2192     if not callable(obj):
-> 2193         raise TypeError('{!r} is not a callable object'.format(obj))
   2194 
   2195     if isinstance(obj, types.MethodType):

TypeError: None is not a callable object

When I use fastai==2.1.5 and fastcore==1.3.2 this problem doesn't exist, but not using the updated fastai would cause other problems when running fastai interpretations eginterp.plot_top_losses.

muellerzr commented 3 years ago

Thanks for pointing this out! Looks like there was one more fastcore issue I needed to solve. Can you try again with installing fastinference like so?

pip install git+https://github.com/muellerzr/fastinference

hududed commented 3 years ago

Hi @muellerzr that seems to have worked! the import and interp.plot_top_losses works as usual.

muellerzr commented 3 years ago

Great! I'll update the pip version later today when I can

muellerzr commented 3 years ago

Updated pip, closing