{"id":13799664,"url":"https://github.com/alsora/ros2-tensorflow","last_synced_at":"2026-04-06T06:35:30.794Z","repository":{"id":110840347,"uuid":"152031690","full_name":"alsora/ros2-tensorflow","owner":"alsora","description":"ROS2 nodes for computer vision tasks in Tensorflow","archived":false,"fork":false,"pushed_at":"2023-04-05T16:14:35.000Z","size":484,"stargazers_count":55,"open_issues_count":2,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T00:04:15.703Z","etag":null,"topics":["computer-vision","image-classification","image-detection","ros2","ros2-tensorflow","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alsora.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-10-08T06:50:55.000Z","updated_at":"2024-05-24T20:49:25.000Z","dependencies_parsed_at":"2024-01-02T23:00:22.704Z","dependency_job_id":"7de8ae1a-a83a-4d88-9c57-1aff8eac66e0","html_url":"https://github.com/alsora/ros2-tensorflow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsora%2Fros2-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsora%2Fros2-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsora%2Fros2-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alsora%2Fros2-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alsora","download_url":"https://codeload.github.com/alsora/ros2-tensorflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225190656,"owners_count":17435459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","image-classification","image-detection","ros2","ros2-tensorflow","tensorflow"],"created_at":"2024-08-04T00:01:04.951Z","updated_at":"2026-04-06T06:35:30.788Z","avatar_url":"https://github.com/alsora.png","language":"Python","funding_links":[],"categories":["Packages"],"sub_categories":["Application layer"],"readme":"# ros2-tensorflow\n\nUse Tensorflow to load pretrained neural networks and perform inference through ROS2 interfaces.\n\n\u003cimg src=\"/data/detection.png\" alt=\"Rviz2 detection output\" width=\"50%\" height=\"50%\"/\u003e\nThe output can be directly visualized through Rviz\n\n## Requirements\n\nIn order to build the `ros2-tensorflow` package, the following dependencies are needed\n\nRequired dependencies:\n - [ROS2 Foxy](https://docs.ros.org/en/foxy/Installation.html)\n\nRosdep dependencies:\n - [OpenCV Python](https://pypi.org/project/opencv-python/)\n - [Tensorflow](https://www.tensorflow.org/install/)\n - [Vision Msgs](https://github.com/Kukanani/vision_msgs)\n\nOptional dependencies:\n - [Tensorflow Object Detection Models](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md) for object detection tasks\n - [TensorFlow-Slim](https://github.com/google-research/tf-slim) for object segmentation tasks\n\nThe provided Dockerfile contains an Ubuntu 18.04 environment with all the dependencies and this package already installed.\n\nTo use the Dockerfile:\n\n    $ git clone https://github.com/alsora/ros2-tensorflow.git\n    $ cd ros2-tensorflow/docker\n    $ bash build.sh\n    $ bash run.sh\n\n## Build\n\nThis section describes how to build the `ros2-tensorflow` package and the required depenencies in case you are not using the provided Dockerfile.\n\nGet the source code and create the ROS 2 workspace\n\n    $ git clone https://github.com/alsora/ros2-tensorflow.git $HOME/ros2-tensorflow\n    $ mkdir -p $HOME/tf_ws/src\n    $ cd $HOME/tf_ws\n    $ ln -s $HOME/ros2-tensorflow/ros2-tensorflow src\n\nInstall required dependencies using rosdep\n\n    $ rosdep install --from-paths src --ignore-src --rosdistro foxy -y\n\nInstall the Tensorflow Object Detection Models (optional).\nMake sure to specify the correct Python version according to your system.\n\n    $ sudo apt-get install -y protobuf-compiler python-lxml python-tk\n    $ pip install --user Cython contextlib2 jupyter matplotlib Pillow\n    $ git clone https://github.com/tensorflow/models.git /usr/local/lib/python3.8/dist-packages/tensorflow/models\n    $ cd usr/local/lib/python3.8/dist-packages/tensorflow/models/research\n    $ protoc object_detection/protos/*.proto --python_out=.\n    $\n    $ echo 'export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.8/dist-packages/tensorflow/models/research' \u003e\u003e $HOME/.bashrc\n\nInstall Tensorflow Slim (optional)\n    \n    $ pip install tf_slim\n\nBuild and install the `ros2-tensorflow` package\n\n    $ colcon build\n    $ source install/local_setup.sh\n\n## Usage\n\nThe basic usage consists in creating a ROS 2 node which loads a Tensorflow model and another ROS 2 node that acts as a client and receives the result of the inference.\n\nIt is possible to specify which model a node should load.\nNote that if the model is specified via url, as it is by default, the first time the node is executed a network connection will be required in order to download the model.\n\n#### Object Detection Task\n\nTest the object detection server by running in separate terminals\n\n    $ ros2 run tf_detection_py server\n    $ ros2 run tf_detection_py client_test\n\nSetup a real object detection pipeline using a stream of images coming from a ROS 2 camera node\n\n    $ rviz2\n    $ ros2 run tf_detection_py server\n    $ ros2 run image_tools cam2image --ros-args -p frequency:=2.0\n\n#### Image Classification Task\n\nTest the image classification server by running in separate terminals\n\n    $ ros2 run tf_classification_py server\n    $ ros2 run tf_classification_py client_test\n\n## Loading different models\n\nThe repository contains convenient APIs for loading Tensorflow models into the ROS 2 nodes.\n\nModels are defined using the `ModelDescriptor` class, which contains all the information required for loading a model and performing inference on it.\nIt can either contain a path where the model can be found on the machine or an URL where the model can be downloaded the first time.\n\nDifferent model formats are also supported, such as frozen models and saved models.\n\nSome known supported models are already present as examples.\nSee [classification models](ros2-tensorflow/tf_classification_py/tf_classification_py/models.py) and [detection models](ros2-tensorflow/tf_detection_py/tf_detection_py/models.py)\n\n\nThe [Tensorflow models repository](https://github.com/tensorflow/models) contains many pretrained models that can be used.\nFor example, you can get additional Tensorflow model for object detection from the [detection model zoo](https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md#coco-trained-models).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsora%2Fros2-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falsora%2Fros2-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falsora%2Fros2-tensorflow/lists"}