Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jsk_recognition_utils] use try to import chainer depend modules #2565

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jsk_recognition_utils/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@
<exec_depend>pcl_msgs</exec_depend>
<exec_depend>pcl_ros</exec_depend>
<exec_depend version_lt="7.0.0">python-chainer-pip</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 2">python-chainercv-pip</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 2">python-skimage</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 3">python3-skimage</exec_depend>
<exec_depend>python-fcn-pip</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>tf2_ros</exec_depend>
Expand Down
57 changes: 55 additions & 2 deletions jsk_recognition_utils/python/jsk_recognition_utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,66 @@
from jsk_recognition_utils import chainermodels
from __future__ import print_function

import sys

from jsk_recognition_utils import color
from jsk_recognition_utils import conversations
from jsk_recognition_utils import datasets
from jsk_recognition_utils import feature
from jsk_recognition_utils import mask
from jsk_recognition_utils import visualize
from jsk_recognition_utils import geometry


try:
import chainer # NOQA
_chainer_available = True
except ImportError:
_chainer_available = False

try:
import chainercv # NOQA
_chainercv_available = True
except ImportError:
_chainercv_available = False

try:
import fcn # NOQA
_fcn_available = True
except ImportError:
_fcn_available = False

if _chainer_available and _chainercv_available and _fcn_available:
from jsk_recognition_utils import chainermodels # NOQA
else:
_depends = []
if not _chainer_available:
_depends.append('chainer\\<7.0.0')
if not _chainercv_available:
_depends.append('chainercv')
if not _fcn_available:
_depends.append('fcn')
print('''
Please install {0}
to import jsk_recognition_utils.chainermodels.

sudo pip install {1}
'''.format(', '.join(_depends), ' '.join(_depends)), file=sys.stderr)

if _chainer_available and _chainercv_available:
from jsk_recognition_utils import datasets # NOQA
else:
_depends = []
if not _chainer_available:
_depends.append('chainer\\<7.0.0')
if not _chainercv_available:
_depends.append('chainercv')
print('''
Please install {0}
to import jsk_recognition_utils.datasets.

sudo pip install {1}
'''.format(', '.join(_depends), ' '.join(_depends)), file=sys.stderr)


bounding_box_msg_to_aabb = conversations.bounding_box_msg_to_aabb
rects_msg_to_ndarray = conversations.rects_msg_to_ndarray

Expand Down