Ask Your Question
0

py-faster-rcnn network detection runs on CPU through ROS callback function

asked 2016-08-03 06:45:58 -0600

WillAndrew gravatar image

updated 2016-08-03 10:56:47 -0600

Hi there,

I'm trying to test my trained py-faster-rcnn network for object detection through ROS. I have a node running with many similarities to demo.py. Included in the class are commands to execute the network detection on the GPU (given below), however, looking at recall times (~26s) and the system profiler it's fairly clear that the network is running on the CPU. Is there a way to get around this?

caffe.set_mode_gpu()
caffe.set_device(0)
cfg.GPU_ID = 0

Interestingly, if I run demo.py normally (not through ROS), it executes on the GPU in ~2s

UPDATE: after some more detective work, it appears that it is an issue with calling CNN detection within a callback function. Any suggestions? (Other people seem to be experiencing a similar problem - Callback with GPU processing)

Thanks, Will

edit retag flag offensive close merge delete

Comments

I don't know anything about caffe, but I do know that rospy runs callbacks in a separate thread from the main loop. Perhaps that helps?

ahendrix gravatar imageahendrix ( 2016-08-03 11:07:28 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-08-04 05:27:15 -0600

WillAndrew gravatar image

Solved the issue by having the callback function change a global variable which is checked by the main loop/thread as follows:

while not rospy.is_shutdown():
    if run_test_img == True:
        testImg()
    rate.sleep()

A bit hacky but it does the job.

edit flag offensive delete link more

Comments

Hi Will. I am also trying to implement faster-rcnn inside the ROS framework. I want to run the demo as a ROS node and pass images on ROS topic. I know how to pass images over a ROS topic but was wondering if there are any dependancy issues when I try to integrate faster rcnn within ROS?

uzair gravatar imageuzair ( 2016-09-19 17:46:30 -0600 )edit
0

answered 2017-01-24 03:47:07 -0600

sjsingh gravatar image

Add these lines in your callback function somewhere at the top

caffe.set_mode_gpu()
caffe.set_device(args.gpu_id)

This works seamlessly. But it doesn't make much sense.

edit flag offensive delete link more

Comments

Why doesn't it make much sense?

gvdhoorn gravatar imagegvdhoorn ( 2017-01-24 04:39:48 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-08-03 06:45:58 -0600

Seen: 787 times

Last updated: Aug 04 '16