Git Product home page Git Product logo

detectron2_ros's Introduction

Detectron2 Object Detector for ROS

A ROS Node for detecting objects using Detectron2.

Installation

It is necessary to install Detectron2 requirements in a python virtual environment as it requires Python 3.6 and ROS works with Python 2.7

  1. Install python Virtual Environment
sudo apt-get install python-pip
sudo pip install virtualenv
mkdir ~/.virtualenvs
sudo pip install virtualenvwrapper
export WORKON_HOME=~/.virtualenvs
echo '. /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc 
  1. Creating Virtual Environment
mkvirtualenv --python=python3 detectron2_ros
  1. Install the dependencies in the virtual environment
pip install -U torch==1.4+cu100 torchvision==0.5+cu100 -f https://download.pytorch.org/whl/torch_stable.html
pip install cython pyyaml==5.1
pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu100/index.html
pip install opencv-python
pip install rospkg

Downloading the Package

  1. Clone the package to the ROS workspace using git tools
git clone https://github.com/DavidFernandezChaves/detectron2_ros.git
cd detectron2_ros
git pull --all
git submodule update --init

Compilation

  1. Attention: DO NOT USE the python virtual environment previously built to compile catking packages.
catkin_make
source $HOME/.bashrc

Running

  1. First launch ROScore into a terminal.

  2. Next, open a new terminal and use the virtual environment created.

workon detectron2_ros
  1. Running the node
roslaunch detectron2_ros detectron2_ros.launch

Arguments

The following arguments can be set on the roslaunch above.

  • input: image topic name
  • detection_threshold: threshold to filter the detection results [0, 1]
  • visualization: True or False to pubish the result like a image
  • model: path to the training model file. For example: /detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml

Citing Detectron

If you use Detectron2 in your research or wish to refer to the baseline results published in the Model Zoo, please use the following BibTeX entry.

@misc{wu2019detectron2,
  author =       {Yuxin Wu and Alexander Kirillov and Francisco Massa and
                  Wan-Yen Lo and Ross Girshick},
  title =        {Detectron2},
  howpublished = {\url{https://github.com/facebookresearch/detectron2}},
  year =         {2019}
}

detectron2_ros's People

Contributors

davidfernandezchaves avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

detectron2_ros's Issues

Can't catkin_make

Hi @DavidFernandezChaves,
Thank you for this great work, While installation i have not face with any problem untill compile. In chapter 4 I kind of confused. I attached 2 image in one of them I was trying to catkin_make inside the workspace in another one outside of workspace. But they both cannot source to ROS. Btw before starting the installation I already sourced to ROS with this "source /opt/ros/melodic/setup.bash" .

I will be happy if you could help me with this one.
Thanks,

Screenshot from 2021-03-05 15-57-21
Screenshot from 2021-03-05 15-57-54

result of panoramic segmentation to ros msg

Thank you very much for your open source. I want to use the panoramic segmentation model, but I don't know whether I can switch to MSG. Does the MSG of this project support this idea?

cv2 import error

Hello,

I believe I followed the instruction on README exactly but I am getting the following error messages. I double-checked that I didn't use the python virtual environment when doing catkin_make. As explained in the instruction, I ran two terminals: one for roscore and the other for running workon detectron2_ros and then roslaunch detectron2_ros detectron2_ros.launch. Could you please help me on this issue?

Traceback (most recent call last):
  File "~/detectron2_ros/src/detectron2_ros/src/detectron2_ros", line 5, in <module>
    import cv2 as cv
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

Model file not found

It is unable to find the "model_final_f10217.pkl" file

process[detectron2_ros-1]: started with pid [14640]
[WARN] [1632167722.433477]: Initializing
[INFO] [1632167722.442250]: [Detectron2] ~config: /home/vikas/detectron_ros/src/detectron2_ros/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml
[INFO] [1632167722.470800]: [Detectron2] ~detection_threshold: 0.5
[INFO] [1632167722.473040]: [Detectron2] ~model: detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
Traceback (most recent call last):
  File "/home/vikas/detectron_ros/src/detectron2_ros/src/detectron2_ros", line 158, in <module>
    main(sys.argv)
  File "/home/vikas/detectron_ros/src/detectron2_ros/src/detectron2_ros", line 154, in main
    node = Detectron2node()
  File "/home/vikas/detectron_ros/src/detectron2_ros/src/detectron2_ros", line 34, in __init__
    self.predictor = DefaultPredictor(self.cfg)
  File "/home/vikas/.virtualenvs/detectron2_ros/lib/python3.8/site-packages/detectron2/engine/defaults.py", line 188, in __init__
    checkpointer.load(cfg.MODEL.WEIGHTS)
  File "/home/vikas/.virtualenvs/detectron2_ros/lib/python3.8/site-packages/fvcore/common/checkpoint.py", line 141, in load
    assert os.path.isfile(path), "Checkpoint {} not found!".format(path)
AssertionError: Checkpoint detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl not found!
[detectron2_ros-1] process has died [pid 14640, exit code 1, cmd /home/vikas/detectron_ros/src/detectron2_ros/src/detectron2_ros __name:=detectron2_ros __log:=/home/vikas/.ros/log/a2aa41ea-1a4c-11ec-8c3f-2d667ddb57ab/detectron2_ros-1.log].
log file: /home/vikas/.ros/log/a2aa41ea-1a4c-11ec-8c3f-2d667ddb57ab/detectron2_ros-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor...
... shutting down processing monitor complete
done

Differentiating b/w .py and no extension

Currently when the repo is cloned detectron2_ros in src does not have the .py extension. Since I was planning on adding one more .py file I decided to rename detectron2_ros to detectron2_ros.py and edit the launch file to reflect that. It started giving can't find detectron2_ros.msg does not exist. Am I missing some other step?

compile and use issues

Hi,@DavidFernandezChaves
Thank you for your great work! I had tried to compile and run your project in a virtual environment created by conda, and the compile process had successuly, however i don't know whether it will work or not by doing like this previously! Now when i run with the command line "roslaunch detectron2_ros detectron2_ros.launch", the output as bellows:
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
[WARN] [1616158634.220835]: Initializing
[INFO] [1616158634.227763]: [Detectron2] ~model: /home/robot_nb/catkin_mask/src/detectron2_ros/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml
shutdown request: [/detectron2_ros] Reason: new node registered with same name
WARNING [03/19 20:57:14 d2.config.compat]: Config '/home/robot_nb/catkin_mask/src/detectron2_ros/detectron2/configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml' has no VERSION. Assuming it to be compatible with latest v2.
[INFO] [1616158634.311513]: [Detectron2] ~detection_threshold: 0.5
[INFO] [1616158651.696466]: [Detectron2] ~visualization: True
[INFO] [1616158651.738531]: [Detectron2] ~input: ViMantic/ToCNN
[WARN] [1616158651.744645]: Initialized
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
It seems that something is wrong, because i can't see the result!
I hope you can tell me whether i can compile and run this project in a virtual environment created by conda? if your answer is yes, then what should i do to acquire the output result and whether the dataset needed?

Best Regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.