Using fastai v1 in ROS

I want to use the Robot Operating System (ROS) with fastai and pytorch inorder to apply what i’ve learnt in this course to the field of robotics.
however when i install conda , i cant use ros anymore. and since the default version of python for ros is python 2.7, i was wondering how i can use fastai and pytorch libraries which depend on python 3 in ros.

ps: a ros node is just a word for a program.

pps:found solution for using ros inside conda env,


ppps: if you’re not using conda,it becomes easy. ros requires a python 2 env so most of its packages work,but many of them(and the most important of them) work with both python2 and 3.
THE BEST WAY would be to have your default python version 2.7 so most packages work,and write your deep learning programs (nodes) in python 3.much easier than using conda.

Did you check this?
Also, Please make sure to include details around what is ROS and what is a ROS node, why would you like to use fastai with ROS, so that others who aren’t familiar with ROS may also be able to help you.

Regards,
Sanyam.

1 Like

thanks for replying.i checked it out and it wasnt the solution.instead,i found a partial solution in this video:


although a partial one,because now i’m unable to use rospy outside of the conda env,but thats okay for now.
and if i didn’t install anaconda,it would’ve been possible to use pytorch and fastai in ros nodes(a ros node is a word for a program,script) without any modification,meaning you can write ros nodes in python 3.

Are you using ROS kinetic by any chance? What sort of robotic applications are you interested in using fastai? I’m trying to get started with simple image/object classification using ROS and fastai. I’m curious to learn how far you’ve been able to get. Thanks!

at the time i was using melodic, but i think even kinetic is compatible with python3. just make sure to indicate in the shebang that you are using python 3. at the time i was interested in implementing an object detection model on a robot. i finished training the model but never finished the implementation with ROS. i think the trickiest part will be that fast ai uses pil while ros images can only be converted to open cv, so u need to make the necessary conversion to each frame.

Also i would advise against using pytorch or fast ai for inference. u always have limited resources on a robot, and u will have to convert images from ros images to open cv and then to pil at each frame. also pytorch is REALLY slow for inference. what i would do is train with fast ai then convert the model to tensorflow using onnx or to caffe, and use that on the robot’s computer.