added missing utils for lime
This commit is contained in:
Родитель
8097818b75
Коммит
485b0235ba
4
setup.py
4
setup.py
|
@ -8,7 +8,7 @@ with open("README.md", "r") as fh:
|
|||
|
||||
setuptools.setup(
|
||||
name="tensorwatch",
|
||||
version="0.8.3",
|
||||
version="0.8.4",
|
||||
author="Shital Shah",
|
||||
author_email="shitals@microsoft.com",
|
||||
description="Interactive Realtime Debugging and Visualization for AI",
|
||||
|
@ -24,6 +24,6 @@ setuptools.setup(
|
|||
),
|
||||
include_package_data=True,
|
||||
install_requires=[
|
||||
'matplotlib', 'numpy', 'pyzmq', 'plotly', 'torchstat', 'receptivefield', 'ipywidgets', 'sklearn', 'nbformat'
|
||||
'matplotlib', 'numpy', 'pyzmq', 'plotly', 'torchstat', 'receptivefield', 'ipywidgets', 'sklearn', 'nbformat', 'skimage'
|
||||
]
|
||||
)
|
|
@ -33,6 +33,7 @@
|
|||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="tensorwatch\receptive_field\__init__.py" />
|
||||
<Compile Include="tensorwatch\saliency\lime\wrappers\generic_utils.py" />
|
||||
<Compile Include="tensorwatch\stream_union.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import sys
|
||||
import inspect
|
||||
import types
|
||||
|
||||
|
||||
def has_arg(fn, arg_name):
|
||||
"""Checks if a callable accepts a given keyword argument.
|
||||
|
||||
Args:
|
||||
fn: callable to inspect
|
||||
arg_name: string, keyword argument name to check
|
||||
|
||||
Returns:
|
||||
bool, whether `fn` accepts a `arg_name` keyword argument.
|
||||
"""
|
||||
if sys.version_info < (3,):
|
||||
if isinstance(fn, types.FunctionType) or isinstance(fn, types.MethodType):
|
||||
arg_spec = inspect.getargspec(fn)
|
||||
else:
|
||||
try:
|
||||
arg_spec = inspect.getargspec(fn.__call__)
|
||||
except AttributeError:
|
||||
return False
|
||||
return (arg_name in arg_spec.args)
|
||||
elif sys.version_info < (3, 6):
|
||||
arg_spec = inspect.getfullargspec(fn)
|
||||
return (arg_name in arg_spec.args or
|
||||
arg_name in arg_spec.kwonlyargs)
|
||||
else:
|
||||
try:
|
||||
signature = inspect.signature(fn)
|
||||
except ValueError:
|
||||
# handling Cython
|
||||
signature = inspect.signature(fn.__call__)
|
||||
parameter = signature.parameters.get(arg_name)
|
||||
if parameter is None:
|
||||
return False
|
||||
return (parameter.kind in (inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
||||
inspect.Parameter.KEYWORD_ONLY))
|
|
@ -1,5 +1,5 @@
|
|||
import types
|
||||
from lime.utils.generic_utils import has_arg
|
||||
from .generic_utils import has_arg
|
||||
from skimage.segmentation import felzenszwalb, slic, quickshift
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче