3 from __future__
import absolute_import
4 from __future__
import division
5 from __future__
import print_function
7 import itertools, pkg_resources, sys
8 from distutils.version
import LooseVersion
9 if LooseVersion(pkg_resources.get_distribution(
"chainer").version) >= LooseVersion(
'7.0.0')
and \
10 sys.version_info.major == 2:
11 print(
'''Please install chainer < 7.0.0: 13 sudo pip install chainer==6.7.0 15 c.f https://github.com/jsk-ros-pkg/jsk_recognition/pull/2485 18 if [p
for p
in list(itertools.chain(*[pkg_resources.find_distributions(_)
for _
in sys.path]))
if "cupy-" in p.project_name ] == []:
19 print(
'''Please install CuPy 21 sudo pip install cupy-cuda[your cuda version] 23 sudo pip install cupy-cuda91 27 import chainer.serializers
as S
28 from jsk_recognition_msgs.msg
import ClassificationResult
32 from sensor_msgs.msg
import Image
33 from vgg16_object_recognition
import VGG16ObjectRecognition
39 super(VGG16ObjectRecognition, self).
__init__()
41 self.
gpu = rospy.get_param(
'~gpu', -1)
46 elif self.
model_name ==
'alexnet_batch_normalization':
47 self.
model = AlexNetBatchNormalization(
50 rospy.logerr(
'Unsupported ~model_name: {0}' 52 model_file = rospy.get_param(
'~model_file')
53 S.load_hdf5(model_file, self.
model)
55 self.model.to_gpu(self.
gpu)
56 self.
pub = self.advertise(
'~output', ClassificationResult,
59 '~debug/net_input', Image, queue_size=1)
62 if __name__ ==
'__main__':
63 rospy.init_node(
'alexnet_object_recognition')