PRBonn / bonnet

Bonnet: An Open-Source Training and Deployment Framework for Semantic Segmentation in Robotics.
GNU General Public License v3.0
323 stars 89 forks source link

Import Error cv2 using docker image #6

Closed srcolinas closed 6 years ago

srcolinas commented 6 years ago

Hi, your repo seems very useful and interesting, I thank you for that.

However, I got the following error trying to make it segment an image:

Traceback (most recent call last):
  File "./cnn_use.py", line 30, in <module>
    import cv2
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

I use the docker image as you explain in the main README.md and try the following comand: ~/bonnet_wrkdir/train_py$ ./cnn_use.py -p city_512/acc/ -i ../test.jpg I had the following folder structure and got the -city_512 from your download link:

- deploy_cpp/
- train_py/
    - city_512/
    - test.jpg

What can I do to make it work? Thanks for your help!

bgheneti commented 6 years ago

I think this needs to run in an environment with python3, not python2, which ros is setup with by default.

https://stackoverflow.com/questions/43019951/after-install-ros-kinetic-cannot-import-opencv

I removed source /opt/ros/kinetic/setup.bash from the bashrc and then added it back after I had created the frozen model. I also had to pip install and apt-get install a few additional packages to get the docker image to work but the necessary packages were evident from the other error statements.

sidenote: Would recommend running docker run w/o --rm during this whole process since you need to exit and reenter the docker image for the bashrc changes to take effect.

tano297 commented 6 years ago

Hi, sorry for the long delay, I've been swamped (and sick). As @bgheneti pointed out, it is a problem with the ros install.

I started modifying the docker file to fix this, but I realized that it made no sense because I will have a major overhaul coming soon to support the latest tensorflow (1.7), the latest tensorrt (4), and the latest versions of cuda and cudnn (9, and 7).

Watch the repo for updates.

tano297 commented 6 years ago

I've made significant changes to the repo and the docker image to work with tensorflow 1.7 and tensorrt 3.0.4, which work well with cuda9 and cudnn7, and in the meantime I also fixed the python cv2 library conflict with ROS. It should be solved now, feel free to reopen if you need any more help.