From 6788fabe9a3e72a51e2ae58c8a3c88331444a25e Mon Sep 17 00:00:00 2001 From: ekakalet Date: Wed, 24 Aug 2022 16:17:24 +0300 Subject: [PATCH 01/82] opendr_ws_ros2 synthetic facial image generation --- .../data_generation/__init__.py | 0 .../synthetic_facial_generation.py | 165 ++++++++++++++++++ .../src/data_generation/package.xml | 18 ++ .../data_generation/resource/data_generation | 0 .../opendr_ws_2/src/data_generation/setup.cfg | 4 + .../opendr_ws_2/src/data_generation/setup.py | 26 +++ .../data_generation/test/test_copyright.py | 23 +++ .../src/data_generation/test/test_flake8.py | 25 +++ .../src/data_generation/test/test_pep257.py | 23 +++ .../opendr_ws_2/src/ros2_bridge/package.xml | 18 ++ .../src/ros2_bridge/resource/ros2_bridge | 0 .../src/ros2_bridge/ros2_bridge/__init__.py | 0 .../src/ros2_bridge/ros2_bridge/bridge.py | 97 ++++++++++ .../opendr_ws_2/src/ros2_bridge/setup.cfg | 4 + projects/opendr_ws_2/src/ros2_bridge/setup.py | 25 +++ .../src/ros2_bridge/test/test_copyright.py | 23 +++ .../src/ros2_bridge/test/test_flake8.py | 25 +++ .../src/ros2_bridge/test/test_pep257.py | 23 +++ projects/opendr_ws_2/src/vision_opencv | 1 + 19 files changed, 500 insertions(+) create mode 100644 projects/opendr_ws_2/src/data_generation/data_generation/__init__.py create mode 100644 projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py create mode 100644 projects/opendr_ws_2/src/data_generation/package.xml create mode 100644 projects/opendr_ws_2/src/data_generation/resource/data_generation create mode 100644 projects/opendr_ws_2/src/data_generation/setup.cfg create mode 100644 projects/opendr_ws_2/src/data_generation/setup.py create mode 100644 projects/opendr_ws_2/src/data_generation/test/test_copyright.py create mode 100644 projects/opendr_ws_2/src/data_generation/test/test_flake8.py create mode 100644 projects/opendr_ws_2/src/data_generation/test/test_pep257.py create mode 100644 projects/opendr_ws_2/src/ros2_bridge/package.xml create mode 100644 projects/opendr_ws_2/src/ros2_bridge/resource/ros2_bridge create mode 100644 projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/__init__.py create mode 100644 projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/bridge.py create mode 100644 projects/opendr_ws_2/src/ros2_bridge/setup.cfg create mode 100644 projects/opendr_ws_2/src/ros2_bridge/setup.py create mode 100644 projects/opendr_ws_2/src/ros2_bridge/test/test_copyright.py create mode 100644 projects/opendr_ws_2/src/ros2_bridge/test/test_flake8.py create mode 100644 projects/opendr_ws_2/src/ros2_bridge/test/test_pep257.py create mode 160000 projects/opendr_ws_2/src/vision_opencv diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/__init__.py b/projects/opendr_ws_2/src/data_generation/data_generation/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py new file mode 100644 index 0000000000..0156b67235 --- /dev/null +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python3.6 +# Copyright 2020-2022 OpenDR European Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import cv2 +import torch +import rclpy +from rclpy.node import Node +from ros2_bridge.bridge import ROS2Bridge +import numpy as np +from sensor_msgs.msg import Image as ROS_Image +from SyntheticDataGeneration import MultiviewDataGenerationLearner +import os +import argparse +from opendr.engine.data import Image + + +class Synthetic_Data_Generation: + + def __init__(self, input_image_topic="/usb_cam/image_raw", output_image_topic="/opendr/synthetic_facial_images", + device="cuda"): + """ + Creates a ROS Node for SyntheticDataGeneration + :param input_image_topic: Topic from which we are reading the input image + :type input_image_topic: str + :param output_image_topic: Topic to which we are publishing the synthetic facial image (if None, we are not publishing + any image) + :type output_image_topic: str + :param device: device on which we are running eval ('cpu' or 'cuda') + :type device: str + """ + + if output_image_topic is not None: + self.image_publisher = rospy.Publisher(output_image_topic, ROS_Image, queue_size=10) + else: + self.image_publisher = None + rospy.Subscriber(input_image_topic, ROS_Image, self.callback) + self.bridge = ROS2Bridge() + self.ID = 0 + + # Initialize the SyntheticDataGeneration + self.parser = argparse.ArgumentParser() + self.parser.add_argument("-device", default="cuda", type=str, help="choose between cuda or cpu ") + self.parser.add_argument("-path_in", default=os.path.join("opendr_internal", "projects", + "data_generation", + "", + "demos", "imgs_input"), + type=str, help='Give the path of image folder') + self.parser.add_argument('-path_3ddfa', default=os.path.join("opendr_internal", "projects", + "data_generation", + "", + "algorithm", "DDFA"), + type=str, help='Give the path of DDFA folder') + self.parser.add_argument('-save_path', default=os.path.join("opendr_internal", "projects", + "data_generation", + "", + "results"), + type=str, help='Give the path of results folder') + self.parser.add_argument('-val_yaw', default="10 20", nargs='+', type=str, help='yaw poses list between [-90,90]') + self.parser.add_argument('-val_pitch', default="30 40", nargs='+', type=str, + help='pitch poses list between [-90,90] ') + self.parser.add_argument('-f', '--files', nargs='+', + help='image files paths fed into network, single or multiple images') + self.parser.add_argument('--show_flg', default='false', type=str2bool, help='whether show the visualization result') + self.parser.add_argument('--dump_res', default='true', type=str2bool, + help='whether write out the visualization image') + self.parser.add_argument('--dump_vertex', default='false', type=str2bool, + help='whether write out the dense face vertices to mat') + self.parser.add_argument('--dump_ply', default='true', type=str2bool) + self.parser.add_argument('--dump_pts', default='true', type=str2bool) + self.parser.add_argument('--dump_roi_box', default='false', type=str2bool) + self.parser.add_argument('--dump_pose', default='true', type=str2bool) + self.parser.add_argument('--dump_depth', default='true', type=str2bool) + self.parser.add_argument('--dump_pncc', default='true', type=str2bool) + self.parser.add_argument('--dump_paf', default='true', type=str2bool) + self.parser.add_argument('--paf_size', default=3, type=int, help='PAF feature kernel size') + self.parser.add_argument('--dump_obj', default='true', type=str2bool) + self.parser.add_argument('--dlib_bbox', default='true', type=str2bool, help='whether use dlib to predict bbox') + self.parser.add_argument('--dlib_landmark', default='true', type=str2bool, + help='whether use dlib landmark to crop image') + self.parser.add_argument('-m', '--mode', default='gpu', type=str, help='gpu or cpu mode') + self.parser.add_argument('--bbox_init', default='two', type=str, help='one|two: one-step bbox initialization or two-step') + self.parser.add_argument('--dump_2d_img', default='true', type=str2bool, help='whether to save 3d rendered image') + self.parser.add_argument('--dump_param', default='true', type=str2bool, help='whether to save param') + self.parser.add_argument('--dump_lmk', default='true', type=str2bool, help='whether to save landmarks') + self.parser.add_argument('--save_dir', default='./algorithm/DDFA/results', type=str, help='dir to save result') + self.parser.add_argument('--save_lmk_dir', default='./example', type=str, help='dir to save landmark result') + self.parser.add_argument('--img_list', default='./txt_name_batch.txt', type=str, help='test image list file') + self.parser.add_argument('--rank', default=0, type=int, help='used when parallel run') + self.parser.add_argument('--world_size', default=1, type=int, help='used when parallel run') + self.parser.add_argument('--resume_idx', default=0, type=int) + self.args = self.parser.parse_args() + self.synthetic = MultiviewDataGeneration(self.args) + + + def callback(self, data): + """ + Callback that process the input data and publishes to the corresponding topics + :param data: input message + :type data: sensor_msgs.msg.Image + """ + + # Convert sensor_msgs.msg.Image into OpenDR Image + + image = self.bridge.from_ros_image(data) + self.ID = self.ID + 1 + # Get an OpenCV image back + image = np.float32(image.numpy()) + name = str(f"{self.ID:02d}"+"_single.jpg") + cv2.imwrite(os.path.join(self.args.path_in, name), image) + + if (self.ID == 5): + # Run SyntheticDataGeneration + self.synthetic.eval() + self.ID = 0 + # Annotate image and publish results + current_directory_path = os.path.join(self.args.save_path, str("/Documents_orig/")) + for file in os.listdir(current_directory_path): + name, ext = os.path.splitext(file) + if ext == ".jpg": + image_file_savepath = os.path.join(current_directory_path, file) + cv_image = cv2.imread(image_file_savepath) + cv_image = cv2.cvtColor(cv_image, cv2.COLOR_BGR2RGB) + if self.image_publisher is not None: + image = Image(np.array(cv_image, dtype=np.uint8)) + message = self.bridge.to_ros_image(image, encoding="bgr8") + self.image_publisher.publish(message) + for f in os.listdir(self.args.path_in): + os.remove(os.path.join(self.args.path_in, f)) + +def main(args=None): + rclpy.init(args=self.args) + try: + if torch.cuda.is_available(): + print("GPU found.") + device = 'cuda' + else: + print("GPU not found. Using CPU instead.") + device = 'cpu' + except: + device = 'cpu' + syntheticdatageneration_node = Synthetic_Data_Generation(device=device) + + rclpy.spin(syntheticdatageneration_node) + + # Destroy the node explicitly + # (optional - otherwise it will be done automatically + # when the garbage collector destroys the node object) + syntheticdatageneration_node.destroy_node() + rclpy.shutdown() + + +if __name__ == '__main__': + main() diff --git a/projects/opendr_ws_2/src/data_generation/package.xml b/projects/opendr_ws_2/src/data_generation/package.xml new file mode 100644 index 0000000000..c4fbb8eb75 --- /dev/null +++ b/projects/opendr_ws_2/src/data_generation/package.xml @@ -0,0 +1,18 @@ + + + + data_generation + 0.0.0 + TODO: Package description + ekakalet + TODO: License declaration + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/projects/opendr_ws_2/src/data_generation/resource/data_generation b/projects/opendr_ws_2/src/data_generation/resource/data_generation new file mode 100644 index 0000000000..e69de29bb2 diff --git a/projects/opendr_ws_2/src/data_generation/setup.cfg b/projects/opendr_ws_2/src/data_generation/setup.cfg new file mode 100644 index 0000000000..6a735acf31 --- /dev/null +++ b/projects/opendr_ws_2/src/data_generation/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script-dir=$base/lib/data_generation +[install] +install-scripts=$base/lib/data_generation diff --git a/projects/opendr_ws_2/src/data_generation/setup.py b/projects/opendr_ws_2/src/data_generation/setup.py new file mode 100644 index 0000000000..3a879b6bd5 --- /dev/null +++ b/projects/opendr_ws_2/src/data_generation/setup.py @@ -0,0 +1,26 @@ +from setuptools import setup + +package_name = 'data_generation' + +setup( + name=package_name, + version='0.0.0', + packages=[package_name], + data_files=[ + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ('share/' + package_name, ['package.xml']), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='ekakalet', + maintainer_email='ekakalets@csd.auth.gr', + description='TODO: Package description', + license='TODO: License declaration', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + 'synthetic_facial_generation = data_generation.synthetic_facial_generation:main' + ], + }, +) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py new file mode 100644 index 0000000000..cc8ff03f79 --- /dev/null +++ b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py @@ -0,0 +1,23 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_copyright.main import main +import pytest + + +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py new file mode 100644 index 0000000000..27ee1078ff --- /dev/null +++ b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py new file mode 100644 index 0000000000..b234a3840f --- /dev/null +++ b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings' diff --git a/projects/opendr_ws_2/src/ros2_bridge/package.xml b/projects/opendr_ws_2/src/ros2_bridge/package.xml new file mode 100644 index 0000000000..cb3f8a0e14 --- /dev/null +++ b/projects/opendr_ws_2/src/ros2_bridge/package.xml @@ -0,0 +1,18 @@ + + + + ros2_bridge + 0.0.0 + TODO: Package description + ekakalet + TODO: License declaration + + ament_copyright + ament_flake8 + ament_pep257 + python3-pytest + + + ament_python + + diff --git a/projects/opendr_ws_2/src/ros2_bridge/resource/ros2_bridge b/projects/opendr_ws_2/src/ros2_bridge/resource/ros2_bridge new file mode 100644 index 0000000000..e69de29bb2 diff --git a/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/__init__.py b/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/bridge.py b/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/bridge.py new file mode 100644 index 0000000000..9d920ec9a9 --- /dev/null +++ b/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/bridge.py @@ -0,0 +1,97 @@ +# Copyright 2020-2022 OpenDR European Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import numpy as np +from opendr.engine.data import Image +from opendr.engine.target import Pose + +from cv_bridge import CvBridge +from sensor_msgs.msg import Image as ImageMsg +from vision_msgs.msg import Detection2DArray, Detection2D, BoundingBox2D, ObjectHypothesisWithPose +from geometry_msgs.msg import Pose2D + + +class ROS2Bridge: + + def __init__(self): + self._cv_bridge = CvBridge() + + def from_ros_image(self, message: ImageMsg, encoding: str='passthrough') -> Image: + # Commented code converts to opencv format without the use of cvbridge + # sz = (message.height, message.width) + # # print(msg.header.stamp) + # + # # print("{encoding} {width} {height} {step} {data_size}".format( + # # encoding=msg.encoding, width=msg.width, height=msg.height, + # # step=msg.step, data_size=len(msg.data))) + # if message.step * message.height != len(message.data): + # print("bad step/height/data size") + # return + # + # if message.encoding == "rgb8": + # img = np.zeros([message.height, message.width, 3], dtype=np.uint8) + # img[:, :, 2] = np.array(message.data[0::3]).reshape(sz) + # img[:, :, 1] = np.array(message.data[1::3]).reshape(sz) + # img[:, :, 0] = np.array(message.data[2::3]).reshape(sz) + # elif message.encoding == "mono8": + # img = np.array(message.data).reshape(sz) + # else: + # print("unsupported encoding {}".format(message.encoding)) + # return + # + # # Convert image from OpenCV format to OpenDR format + # return Image(np.asarray(img, dtype=np.uint8)) + + cv_image = self._cv_bridge.imgmsg_to_cv2(message, desired_encoding=encoding) + image = Image(np.asarray(cv_image, dtype=np.uint8)) + return image + + def to_ros_image(self, image: Image, encoding: str='passthrough') -> ImageMsg: + # Convert from the OpenDR standard (CHW/RGB) to OpenCV standard (HWC/BGR) + message = self._cv_bridge.cv2_to_imgmsg(image.opencv(), encoding=encoding) + return message + + def to_ros_pose(self, pose): + data = pose.data + keypoints = Detection2DArray() + for i in range(data.shape[0]): + keypoint = Detection2D() + keypoint.bbox = BoundingBox2D() + keypoint.results.append(ObjectHypothesisWithPose()) + keypoint.bbox.center = Pose2D() + keypoint.bbox.center.x = float(data[i][0]) + keypoint.bbox.center.y = float(data[i][1]) + keypoint.bbox.size_x = 0.0 + keypoint.bbox.size_y = 0.0 + keypoint.results[0].id = str(pose.id) + if pose.confidence: + keypoint.results[0].score = pose.confidence + keypoints.detections.append(keypoint) + return keypoints + + def from_ros_pose(self, ros_pose): + keypoints = ros_pose.detections + data = [] + pose_id, confidence = None, None + + for keypoint in keypoints: + data.append(keypoint.bbox.center.x) + data.append(keypoint.bbox.center.y) + confidence = keypoint.results[0].score + pose_id = keypoint.results[0].id + data = np.asarray(data).reshape((-1, 2)) + + pose = Pose(data, confidence) + pose.id = pose_id + return pose diff --git a/projects/opendr_ws_2/src/ros2_bridge/setup.cfg b/projects/opendr_ws_2/src/ros2_bridge/setup.cfg new file mode 100644 index 0000000000..464569a1e6 --- /dev/null +++ b/projects/opendr_ws_2/src/ros2_bridge/setup.cfg @@ -0,0 +1,4 @@ +[develop] +script-dir=$base/lib/ros2_bridge +[install] +install-scripts=$base/lib/ros2_bridge diff --git a/projects/opendr_ws_2/src/ros2_bridge/setup.py b/projects/opendr_ws_2/src/ros2_bridge/setup.py new file mode 100644 index 0000000000..9162229007 --- /dev/null +++ b/projects/opendr_ws_2/src/ros2_bridge/setup.py @@ -0,0 +1,25 @@ +from setuptools import setup + +package_name = 'ros2_bridge' + +setup( + name=package_name, + version='0.0.0', + packages=[package_name], + data_files=[ + ('share/ament_index/resource_index/packages', + ['resource/' + package_name]), + ('share/' + package_name, ['package.xml']), + ], + install_requires=['setuptools'], + zip_safe=True, + maintainer='ekakalet', + maintainer_email='ekakalets@csd.auth.gr', + description='TODO: Package description', + license='TODO: License declaration', + tests_require=['pytest'], + entry_points={ + 'console_scripts': [ + ], + }, +) diff --git a/projects/opendr_ws_2/src/ros2_bridge/test/test_copyright.py b/projects/opendr_ws_2/src/ros2_bridge/test/test_copyright.py new file mode 100644 index 0000000000..cc8ff03f79 --- /dev/null +++ b/projects/opendr_ws_2/src/ros2_bridge/test/test_copyright.py @@ -0,0 +1,23 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_copyright.main import main +import pytest + + +@pytest.mark.copyright +@pytest.mark.linter +def test_copyright(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found errors' diff --git a/projects/opendr_ws_2/src/ros2_bridge/test/test_flake8.py b/projects/opendr_ws_2/src/ros2_bridge/test/test_flake8.py new file mode 100644 index 0000000000..27ee1078ff --- /dev/null +++ b/projects/opendr_ws_2/src/ros2_bridge/test/test_flake8.py @@ -0,0 +1,25 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_flake8.main import main_with_errors +import pytest + + +@pytest.mark.flake8 +@pytest.mark.linter +def test_flake8(): + rc, errors = main_with_errors(argv=[]) + assert rc == 0, \ + 'Found %d code style errors / warnings:\n' % len(errors) + \ + '\n'.join(errors) diff --git a/projects/opendr_ws_2/src/ros2_bridge/test/test_pep257.py b/projects/opendr_ws_2/src/ros2_bridge/test/test_pep257.py new file mode 100644 index 0000000000..b234a3840f --- /dev/null +++ b/projects/opendr_ws_2/src/ros2_bridge/test/test_pep257.py @@ -0,0 +1,23 @@ +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from ament_pep257.main import main +import pytest + + +@pytest.mark.linter +@pytest.mark.pep257 +def test_pep257(): + rc = main(argv=['.', 'test']) + assert rc == 0, 'Found code style errors / warnings' diff --git a/projects/opendr_ws_2/src/vision_opencv b/projects/opendr_ws_2/src/vision_opencv new file mode 160000 index 0000000000..0b69de3895 --- /dev/null +++ b/projects/opendr_ws_2/src/vision_opencv @@ -0,0 +1 @@ +Subproject commit 0b69de38953f21090ac62bc90eb700e8bc98a023 From 24da6cb67cd3461453c97e7c42248b03af7d772d Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:34:41 +0300 Subject: [PATCH 02/82] Delete projects/opendr_ws_2/src/ros2_bridge directory delete directory --- .../opendr_ws_2/src/ros2_bridge/package.xml | 18 ---- .../src/ros2_bridge/resource/ros2_bridge | 0 .../src/ros2_bridge/ros2_bridge/__init__.py | 0 .../src/ros2_bridge/ros2_bridge/bridge.py | 97 ------------------- .../opendr_ws_2/src/ros2_bridge/setup.cfg | 4 - projects/opendr_ws_2/src/ros2_bridge/setup.py | 25 ----- .../src/ros2_bridge/test/test_copyright.py | 23 ----- .../src/ros2_bridge/test/test_flake8.py | 25 ----- .../src/ros2_bridge/test/test_pep257.py | 23 ----- 9 files changed, 215 deletions(-) delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/package.xml delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/resource/ros2_bridge delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/__init__.py delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/bridge.py delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/setup.cfg delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/setup.py delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/test/test_copyright.py delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/test/test_flake8.py delete mode 100644 projects/opendr_ws_2/src/ros2_bridge/test/test_pep257.py diff --git a/projects/opendr_ws_2/src/ros2_bridge/package.xml b/projects/opendr_ws_2/src/ros2_bridge/package.xml deleted file mode 100644 index cb3f8a0e14..0000000000 --- a/projects/opendr_ws_2/src/ros2_bridge/package.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - ros2_bridge - 0.0.0 - TODO: Package description - ekakalet - TODO: License declaration - - ament_copyright - ament_flake8 - ament_pep257 - python3-pytest - - - ament_python - - diff --git a/projects/opendr_ws_2/src/ros2_bridge/resource/ros2_bridge b/projects/opendr_ws_2/src/ros2_bridge/resource/ros2_bridge deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/__init__.py b/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/bridge.py b/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/bridge.py deleted file mode 100644 index 9d920ec9a9..0000000000 --- a/projects/opendr_ws_2/src/ros2_bridge/ros2_bridge/bridge.py +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright 2020-2022 OpenDR European Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import numpy as np -from opendr.engine.data import Image -from opendr.engine.target import Pose - -from cv_bridge import CvBridge -from sensor_msgs.msg import Image as ImageMsg -from vision_msgs.msg import Detection2DArray, Detection2D, BoundingBox2D, ObjectHypothesisWithPose -from geometry_msgs.msg import Pose2D - - -class ROS2Bridge: - - def __init__(self): - self._cv_bridge = CvBridge() - - def from_ros_image(self, message: ImageMsg, encoding: str='passthrough') -> Image: - # Commented code converts to opencv format without the use of cvbridge - # sz = (message.height, message.width) - # # print(msg.header.stamp) - # - # # print("{encoding} {width} {height} {step} {data_size}".format( - # # encoding=msg.encoding, width=msg.width, height=msg.height, - # # step=msg.step, data_size=len(msg.data))) - # if message.step * message.height != len(message.data): - # print("bad step/height/data size") - # return - # - # if message.encoding == "rgb8": - # img = np.zeros([message.height, message.width, 3], dtype=np.uint8) - # img[:, :, 2] = np.array(message.data[0::3]).reshape(sz) - # img[:, :, 1] = np.array(message.data[1::3]).reshape(sz) - # img[:, :, 0] = np.array(message.data[2::3]).reshape(sz) - # elif message.encoding == "mono8": - # img = np.array(message.data).reshape(sz) - # else: - # print("unsupported encoding {}".format(message.encoding)) - # return - # - # # Convert image from OpenCV format to OpenDR format - # return Image(np.asarray(img, dtype=np.uint8)) - - cv_image = self._cv_bridge.imgmsg_to_cv2(message, desired_encoding=encoding) - image = Image(np.asarray(cv_image, dtype=np.uint8)) - return image - - def to_ros_image(self, image: Image, encoding: str='passthrough') -> ImageMsg: - # Convert from the OpenDR standard (CHW/RGB) to OpenCV standard (HWC/BGR) - message = self._cv_bridge.cv2_to_imgmsg(image.opencv(), encoding=encoding) - return message - - def to_ros_pose(self, pose): - data = pose.data - keypoints = Detection2DArray() - for i in range(data.shape[0]): - keypoint = Detection2D() - keypoint.bbox = BoundingBox2D() - keypoint.results.append(ObjectHypothesisWithPose()) - keypoint.bbox.center = Pose2D() - keypoint.bbox.center.x = float(data[i][0]) - keypoint.bbox.center.y = float(data[i][1]) - keypoint.bbox.size_x = 0.0 - keypoint.bbox.size_y = 0.0 - keypoint.results[0].id = str(pose.id) - if pose.confidence: - keypoint.results[0].score = pose.confidence - keypoints.detections.append(keypoint) - return keypoints - - def from_ros_pose(self, ros_pose): - keypoints = ros_pose.detections - data = [] - pose_id, confidence = None, None - - for keypoint in keypoints: - data.append(keypoint.bbox.center.x) - data.append(keypoint.bbox.center.y) - confidence = keypoint.results[0].score - pose_id = keypoint.results[0].id - data = np.asarray(data).reshape((-1, 2)) - - pose = Pose(data, confidence) - pose.id = pose_id - return pose diff --git a/projects/opendr_ws_2/src/ros2_bridge/setup.cfg b/projects/opendr_ws_2/src/ros2_bridge/setup.cfg deleted file mode 100644 index 464569a1e6..0000000000 --- a/projects/opendr_ws_2/src/ros2_bridge/setup.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[develop] -script-dir=$base/lib/ros2_bridge -[install] -install-scripts=$base/lib/ros2_bridge diff --git a/projects/opendr_ws_2/src/ros2_bridge/setup.py b/projects/opendr_ws_2/src/ros2_bridge/setup.py deleted file mode 100644 index 9162229007..0000000000 --- a/projects/opendr_ws_2/src/ros2_bridge/setup.py +++ /dev/null @@ -1,25 +0,0 @@ -from setuptools import setup - -package_name = 'ros2_bridge' - -setup( - name=package_name, - version='0.0.0', - packages=[package_name], - data_files=[ - ('share/ament_index/resource_index/packages', - ['resource/' + package_name]), - ('share/' + package_name, ['package.xml']), - ], - install_requires=['setuptools'], - zip_safe=True, - maintainer='ekakalet', - maintainer_email='ekakalets@csd.auth.gr', - description='TODO: Package description', - license='TODO: License declaration', - tests_require=['pytest'], - entry_points={ - 'console_scripts': [ - ], - }, -) diff --git a/projects/opendr_ws_2/src/ros2_bridge/test/test_copyright.py b/projects/opendr_ws_2/src/ros2_bridge/test/test_copyright.py deleted file mode 100644 index cc8ff03f79..0000000000 --- a/projects/opendr_ws_2/src/ros2_bridge/test/test_copyright.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_copyright.main import main -import pytest - - -@pytest.mark.copyright -@pytest.mark.linter -def test_copyright(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found errors' diff --git a/projects/opendr_ws_2/src/ros2_bridge/test/test_flake8.py b/projects/opendr_ws_2/src/ros2_bridge/test/test_flake8.py deleted file mode 100644 index 27ee1078ff..0000000000 --- a/projects/opendr_ws_2/src/ros2_bridge/test/test_flake8.py +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_flake8.main import main_with_errors -import pytest - - -@pytest.mark.flake8 -@pytest.mark.linter -def test_flake8(): - rc, errors = main_with_errors(argv=[]) - assert rc == 0, \ - 'Found %d code style errors / warnings:\n' % len(errors) + \ - '\n'.join(errors) diff --git a/projects/opendr_ws_2/src/ros2_bridge/test/test_pep257.py b/projects/opendr_ws_2/src/ros2_bridge/test/test_pep257.py deleted file mode 100644 index b234a3840f..0000000000 --- a/projects/opendr_ws_2/src/ros2_bridge/test/test_pep257.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from ament_pep257.main import main -import pytest - - -@pytest.mark.linter -@pytest.mark.pep257 -def test_pep257(): - rc = main(argv=['.', 'test']) - assert rc == 0, 'Found code style errors / warnings' From b0d89078a78c365f743f79ea0acacf6f1ac83cff Mon Sep 17 00:00:00 2001 From: ekakalet Date: Wed, 24 Aug 2022 16:40:04 +0300 Subject: [PATCH 03/82] delete unneccesary directory --- projects/opendr_ws_2/src/vision_opencv | 1 - 1 file changed, 1 deletion(-) delete mode 160000 projects/opendr_ws_2/src/vision_opencv diff --git a/projects/opendr_ws_2/src/vision_opencv b/projects/opendr_ws_2/src/vision_opencv deleted file mode 160000 index 0b69de3895..0000000000 --- a/projects/opendr_ws_2/src/vision_opencv +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0b69de38953f21090ac62bc90eb700e8bc98a023 From f6864570125f87603d047a71a5c25e0be26c783e Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:53:19 +0300 Subject: [PATCH 04/82] Update README.md change to be correct the execution of the module --- .../synthetic_multi_view_facial_image_generation/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/data_generation/synthetic_multi_view_facial_image_generation/README.md b/projects/data_generation/synthetic_multi_view_facial_image_generation/README.md index c8a650489d..dce7a7de7d 100644 --- a/projects/data_generation/synthetic_multi_view_facial_image_generation/README.md +++ b/projects/data_generation/synthetic_multi_view_facial_image_generation/README.md @@ -44,7 +44,7 @@ wget https://github.com/cleardusk/3DDFA/blob/master/models/phase1_wpdc_vdc.pth.t 1. Execute the one-step OPENDR function ```tool_synthetic_facial_generation.py``` specifying the input images folder, the output folder, the desired degrees (range -90 to 90) for generating the facial images in multiple view angles pitch and yaw as indicated in the command line: ```sh -python3 tool_synthetic_facial_generation.py -path_in ./demos/imgs_input/ -path_3ddfa ./algorithm/DDFA/ -save_path ./results -val_yaw 10, 40 -val_pitch 10, 30 -device cuda +python3 tool_synthetic_facial_generation.py -path_in ./demos/imgs_input/ -path_3ddfa ./algorithm/DDFA/ -save_path ./results -val_yaw 10 40 -val_pitch 10 30 -device cuda ``` 3. The results can be found in ```results/rs_model/example/```, where multi-view facial images are generated for every person in a respective folder. From f15053b0c260b9ccb28765b5051fec5e6ebd33a9 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:57:56 +0300 Subject: [PATCH 05/82] Update package.xml change to be correct --- projects/opendr_ws_2/src/data_generation/package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/package.xml b/projects/opendr_ws_2/src/data_generation/package.xml index c4fbb8eb75..eb582d2fc0 100644 --- a/projects/opendr_ws_2/src/data_generation/package.xml +++ b/projects/opendr_ws_2/src/data_generation/package.xml @@ -4,7 +4,7 @@ data_generation 0.0.0 TODO: Package description - ekakalet + tefas TODO: License declaration ament_copyright From 75340c3fbf0e5cac3237b996c33a62da9930c000 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Wed, 24 Aug 2022 16:59:21 +0300 Subject: [PATCH 06/82] Update setup.py --- projects/opendr_ws_2/src/data_generation/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/setup.py b/projects/opendr_ws_2/src/data_generation/setup.py index 3a879b6bd5..829a220baa 100644 --- a/projects/opendr_ws_2/src/data_generation/setup.py +++ b/projects/opendr_ws_2/src/data_generation/setup.py @@ -13,8 +13,8 @@ ], install_requires=['setuptools'], zip_safe=True, - maintainer='ekakalet', - maintainer_email='ekakalets@csd.auth.gr', + maintainer='OpenDR Project Coordinator', + maintainer_email='tefas@csd.auth.gr', description='TODO: Package description', license='TODO: License declaration', tests_require=['pytest'], From 139fee0b9741d43944d0e7eb9347848be1ba2279 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Wed, 24 Aug 2022 17:00:59 +0300 Subject: [PATCH 07/82] Update package.xml --- projects/opendr_ws_2/src/data_generation/package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/package.xml b/projects/opendr_ws_2/src/data_generation/package.xml index eb582d2fc0..23b313c0d1 100644 --- a/projects/opendr_ws_2/src/data_generation/package.xml +++ b/projects/opendr_ws_2/src/data_generation/package.xml @@ -3,7 +3,7 @@ data_generation 0.0.0 - TODO: Package description + ROS 2 module for synthetic multiview facial image generation/description> tefas TODO: License declaration From 0b779d2f675052f65a61a6cdaf5c9871c7519fe7 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Wed, 24 Aug 2022 17:02:54 +0300 Subject: [PATCH 08/82] Update package.xml --- projects/opendr_ws_2/src/data_generation/package.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/package.xml b/projects/opendr_ws_2/src/data_generation/package.xml index 23b313c0d1..f6bb14c2c4 100644 --- a/projects/opendr_ws_2/src/data_generation/package.xml +++ b/projects/opendr_ws_2/src/data_generation/package.xml @@ -2,10 +2,10 @@ data_generation - 0.0.0 - ROS 2 module for synthetic multiview facial image generation/description> + 1.0.0 + OpenDR ROS2 node for synthetic multiview facial image generation/description> tefas - TODO: License declaration + Apache License v2.0 ament_copyright ament_flake8 From 7edafb915ec6fde6d76a142182e3dfa5f8a92eda Mon Sep 17 00:00:00 2001 From: ekakalet Date: Thu, 25 Aug 2022 10:54:22 +0300 Subject: [PATCH 09/82] prepared with test --- .../data_generation/synthetic_facial_generation.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 0156b67235..367db9d844 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -90,7 +90,8 @@ def __init__(self, input_image_topic="/usb_cam/image_raw", output_image_topic="/ self.parser.add_argument('--dlib_landmark', default='true', type=str2bool, help='whether use dlib landmark to crop image') self.parser.add_argument('-m', '--mode', default='gpu', type=str, help='gpu or cpu mode') - self.parser.add_argument('--bbox_init', default='two', type=str, help='one|two: one-step bbox initialization or two-step') + self.parser.add_argument('--bbox_init', default='two', type=str, + help='one|two: one-step bbox initialization or two-step') self.parser.add_argument('--dump_2d_img', default='true', type=str2bool, help='whether to save 3d rendered image') self.parser.add_argument('--dump_param', default='true', type=str2bool, help='whether to save param') self.parser.add_argument('--dump_lmk', default='true', type=str2bool, help='whether to save landmarks') @@ -101,8 +102,7 @@ def __init__(self, input_image_topic="/usb_cam/image_raw", output_image_topic="/ self.parser.add_argument('--world_size', default=1, type=int, help='used when parallel run') self.parser.add_argument('--resume_idx', default=0, type=int) self.args = self.parser.parse_args() - self.synthetic = MultiviewDataGeneration(self.args) - + self.synthetic = MultiviewDataGeneration(self.args) def callback(self, data): """ @@ -112,7 +112,7 @@ def callback(self, data): """ # Convert sensor_msgs.msg.Image into OpenDR Image - + image = self.bridge.from_ros_image(data) self.ID = self.ID + 1 # Get an OpenCV image back @@ -139,6 +139,7 @@ def callback(self, data): for f in os.listdir(self.args.path_in): os.remove(os.path.join(self.args.path_in, f)) + def main(args=None): rclpy.init(args=self.args) try: From e1d2d88d6892f1fac761e35644e612d2db2fe81f Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 29 Aug 2022 17:00:31 +0300 Subject: [PATCH 10/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 367db9d844..3795e64a1b 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -20,10 +20,11 @@ from ros2_bridge.bridge import ROS2Bridge import numpy as np from sensor_msgs.msg import Image as ROS_Image -from SyntheticDataGeneration import MultiviewDataGenerationLearner +from SyntheticDataGeneration import MultiviewDataGeneration import os import argparse from opendr.engine.data import Image +from algorithm.DDFA.utils.ddfa import str2bool class Synthetic_Data_Generation: @@ -42,10 +43,10 @@ def __init__(self, input_image_topic="/usb_cam/image_raw", output_image_topic="/ """ if output_image_topic is not None: - self.image_publisher = rospy.Publisher(output_image_topic, ROS_Image, queue_size=10) + self.image_publisher = self.create_publisher(output_image_topic, ROS_Image, queue_size=10) else: self.image_publisher = None - rospy.Subscriber(input_image_topic, ROS_Image, self.callback) + self.create_subscription(input_image_topic, ROS_Image, self.callback) self.bridge = ROS2Bridge() self.ID = 0 From 03e3355c47e5aea4dd3fd4060a386416ff5f020c Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 29 Aug 2022 17:52:57 +0300 Subject: [PATCH 11/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 3795e64a1b..5726402dd6 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -25,6 +25,7 @@ import argparse from opendr.engine.data import Image from algorithm.DDFA.utils.ddfa import str2bool +__all__ = ['rclpy.node.Node'] class Synthetic_Data_Generation: @@ -142,7 +143,7 @@ def callback(self, data): def main(args=None): - rclpy.init(args=self.args) + rclpy.init(args=args) try: if torch.cuda.is_available(): print("GPU found.") From 1a2fa94919fe89fed14a5fa5a94483d10c73d706 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:10:01 +0300 Subject: [PATCH 12/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 5726402dd6..e9324fe6b3 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -16,7 +16,6 @@ import cv2 import torch import rclpy -from rclpy.node import Node from ros2_bridge.bridge import ROS2Bridge import numpy as np from sensor_msgs.msg import Image as ROS_Image @@ -25,7 +24,6 @@ import argparse from opendr.engine.data import Image from algorithm.DDFA.utils.ddfa import str2bool -__all__ = ['rclpy.node.Node'] class Synthetic_Data_Generation: From 33e51cdf11c791c62eaa481a65262f94fea9fb85 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 30 Aug 2022 11:55:54 +0300 Subject: [PATCH 13/82] Update setup.py --- projects/opendr_ws_2/src/data_generation/setup.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/projects/opendr_ws_2/src/data_generation/setup.py b/projects/opendr_ws_2/src/data_generation/setup.py index 829a220baa..f5c3f4c3ae 100644 --- a/projects/opendr_ws_2/src/data_generation/setup.py +++ b/projects/opendr_ws_2/src/data_generation/setup.py @@ -1,3 +1,17 @@ +# Copyright 2020-2022 OpenDR European Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from setuptools import setup package_name = 'data_generation' From 25227e9ce8b431c67d6575c1ef518a530918d293 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:53:58 +0300 Subject: [PATCH 14/82] Update test_pep257.py --- projects/opendr_ws_2/src/data_generation/test/test_pep257.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py index b234a3840f..86bd3a63c3 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py @@ -1,4 +1,4 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. +# Copyright 2020-2022 OpenDR European Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 7424a97bb1a676a1cc92e124c374a51c7d79e000 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:54:21 +0300 Subject: [PATCH 15/82] Update test_flake8.py --- projects/opendr_ws_2/src/data_generation/test/test_flake8.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py index 27ee1078ff..7312f475c3 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py @@ -1,4 +1,4 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. +# Copyright 2020-2022 OpenDR European Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 47f0ef7d3a36f67c66e6a2205a3c517cb3f7680d Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 30 Aug 2022 14:54:38 +0300 Subject: [PATCH 16/82] Update test_copyright.py --- projects/opendr_ws_2/src/data_generation/test/test_copyright.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py index cc8ff03f79..cbb6ecf765 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py @@ -1,4 +1,4 @@ -# Copyright 2015 Open Source Robotics Foundation, Inc. +# Copyright 2020-2022 OpenDR European Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 7fb50952de695aea9170b6f48dbf6d8c54e5606e Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 30 Aug 2022 16:23:00 +0300 Subject: [PATCH 17/82] Update mesh_util.py --- .../human_model_generation/utilities/PIFu/lib/mesh_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opendr/simulation/human_model_generation/utilities/PIFu/lib/mesh_util.py b/src/opendr/simulation/human_model_generation/utilities/PIFu/lib/mesh_util.py index d1c450ff9e..0ad38a66f1 100644 --- a/src/opendr/simulation/human_model_generation/utilities/PIFu/lib/mesh_util.py +++ b/src/opendr/simulation/human_model_generation/utilities/PIFu/lib/mesh_util.py @@ -42,7 +42,7 @@ def eval_func(points): # Finally we do marching cubes try: - verts, faces, normals, values = measure.marching_cubes_lewiner(sdf, 0.5) + verts, faces, normals, values = measure.marching_cubes(sdf, 0.5) # transform verts into world coordinate system verts = np.matmul(mat[:3, :3], verts.T) + mat[:3, 3:4] verts = verts.T From 0e11befdf7b753c268e3b5292e792108656722bf Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:11:38 +0300 Subject: [PATCH 18/82] Update Dockerfile-cuda Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- Dockerfile-cuda | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile-cuda b/Dockerfile-cuda index 26c6cc3178..8f2ce81791 100644 --- a/Dockerfile-cuda +++ b/Dockerfile-cuda @@ -6,7 +6,7 @@ ARG branch=master ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu$(cat /etc/os-release | grep VERSION_ID | awk '{print substr($0,13,5)}' | awk -F'.' '{print $1$2}')/x86_64/3bf863cc.pub -ARG branch +ARG branch=develop # Install dependencies RUN apt-get update && \ From 706384d9b9080aae6cf95a21915e7d55a59f0b63 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:16:19 +0300 Subject: [PATCH 19/82] Update .github/workflows/tests_suite_develop.yml Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .github/workflows/tests_suite_develop.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests_suite_develop.yml b/.github/workflows/tests_suite_develop.yml index 71076a2ec8..bf5ac56a24 100644 --- a/.github/workflows/tests_suite_develop.yml +++ b/.github/workflows/tests_suite_develop.yml @@ -375,7 +375,6 @@ jobs: name: docker-artifact delete-wheel-artifacts: needs: [build-wheel, test-wheel, test-wheel-separate] - if: ${{ always() }} strategy: matrix: From 044b403afb14471020d5a47f4f21ffa8a7d0dd78 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:17:00 +0300 Subject: [PATCH 20/82] Update .github/workflows/tests_suite_develop.yml Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .github/workflows/tests_suite_develop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests_suite_develop.yml b/.github/workflows/tests_suite_develop.yml index bf5ac56a24..c826152349 100644 --- a/.github/workflows/tests_suite_develop.yml +++ b/.github/workflows/tests_suite_develop.yml @@ -180,6 +180,7 @@ jobs: - perception/multimodal_human_centric - perception/object_tracking_2d - perception/pose_estimation + - perception/fall_detection - perception/speech_recognition - perception/skeleton_based_action_recognition - perception/semantic_segmentation From 0c08275407d083dfd606db6f9d5e6d87576867cc Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:17:42 +0300 Subject: [PATCH 21/82] Update projects/opendr_ws_2/src/data_generation/package.xml Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- projects/opendr_ws_2/src/data_generation/package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/package.xml b/projects/opendr_ws_2/src/data_generation/package.xml index f6bb14c2c4..b5fce32684 100644 --- a/projects/opendr_ws_2/src/data_generation/package.xml +++ b/projects/opendr_ws_2/src/data_generation/package.xml @@ -3,7 +3,7 @@ data_generation 1.0.0 - OpenDR ROS2 node for synthetic multiview facial image generation/description> + OpenDR ROS2 node for synthetic multiview facial image generation tefas Apache License v2.0 From 46c232e44f73b5d877e471df4518fbe2bdf5b5b5 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:21:27 +0300 Subject: [PATCH 22/82] Update test_copyright.py --- .../src/data_generation/test/test_copyright.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py index cbb6ecf765..5c87e1e36d 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py @@ -1,17 +1,3 @@ -# Copyright 2020-2022 OpenDR European Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - from ament_copyright.main import main import pytest From a08894370be032d2e172225f490c7a4d2f36893d Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:21:48 +0300 Subject: [PATCH 23/82] Update test_flake8.py --- .../src/data_generation/test/test_flake8.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py index 7312f475c3..63b55be7a9 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py @@ -1,17 +1,3 @@ -# Copyright 2020-2022 OpenDR European Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - from ament_flake8.main import main_with_errors import pytest From e197dc06b3da23ac89b8c0dcaa7cf6d9a476170c Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:22:03 +0300 Subject: [PATCH 24/82] Update test_pep257.py --- .../src/data_generation/test/test_pep257.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py index 86bd3a63c3..4795382c6b 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py @@ -1,17 +1,3 @@ -# Copyright 2020-2022 OpenDR European Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - from ament_pep257.main import main import pytest From bb45147dafd10455febfc3dd79bd774a4ac9bf71 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:26:49 +0300 Subject: [PATCH 25/82] Update test_license.py --- tests/test_license.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_license.py b/tests/test_license.py index 9b89d2ed73..bc15711c03 100755 --- a/tests/test_license.py +++ b/tests/test_license.py @@ -107,6 +107,7 @@ def setUp(self): 'src/opendr/perception/facial_expression_recognition/landmark_based_facial_expression_recognition', 'projects/opendr_ws_2/src/opendr_perception/test', 'projects/opendr_ws_2/src/opendr_ros2_bridge/test', + 'projects/opendr_ws_2/src/data_generation/test/', ] skippedFilePaths = [ @@ -121,6 +122,7 @@ def setUp(self): 'src/opendr/perception/multimodal_human_centric/audiovisual_emotion_learner/algorithm/utils.py', 'projects/opendr_ws_2/src/opendr_perception/setup.py', 'projects/opendr_ws_2/src/opendr_ros2_bridge/setup.py', + 'projects/opendr_ws_2/src/data_generation/setup.py', ] skippedDirectories = [ From b04006efd180cb66bac85a697ab74536e66df5f1 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:28:19 +0300 Subject: [PATCH 26/82] Update projects/opendr_ws_2/src/data_generation/setup.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- projects/opendr_ws_2/src/data_generation/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/setup.py b/projects/opendr_ws_2/src/data_generation/setup.py index f5c3f4c3ae..34e3e7ec4c 100644 --- a/projects/opendr_ws_2/src/data_generation/setup.py +++ b/projects/opendr_ws_2/src/data_generation/setup.py @@ -18,7 +18,7 @@ setup( name=package_name, - version='0.0.0', + version='1.0.0', packages=[package_name], data_files=[ ('share/ament_index/resource_index/packages', From fb9437aebef05c197fd78a3834b5135156b9327f Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:28:57 +0300 Subject: [PATCH 27/82] Update projects/opendr_ws_2/src/data_generation/setup.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- projects/opendr_ws_2/src/data_generation/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/setup.py b/projects/opendr_ws_2/src/data_generation/setup.py index 34e3e7ec4c..b810963785 100644 --- a/projects/opendr_ws_2/src/data_generation/setup.py +++ b/projects/opendr_ws_2/src/data_generation/setup.py @@ -29,8 +29,8 @@ zip_safe=True, maintainer='OpenDR Project Coordinator', maintainer_email='tefas@csd.auth.gr', - description='TODO: Package description', - license='TODO: License declaration', + description='OpenDR ROS2 node for synthetic multiview facial image generation', + license='Apache License v2.0', tests_require=['pytest'], entry_points={ 'console_scripts': [ From fff56e69f709dad1ed8efbeefd774f305802f9ef Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:29:47 +0300 Subject: [PATCH 28/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index e9324fe6b3..19a17e04aa 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -26,7 +26,7 @@ from algorithm.DDFA.utils.ddfa import str2bool -class Synthetic_Data_Generation: +class SyntheticDataGeneration(Node): def __init__(self, input_image_topic="/usb_cam/image_raw", output_image_topic="/opendr/synthetic_facial_images", device="cuda"): From 5f3789ff46751aca97a4c8ffe74325e18dace456 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:30:50 +0300 Subject: [PATCH 29/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 19a17e04aa..9f9ebb2efb 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -16,6 +16,7 @@ import cv2 import torch import rclpy +from rclpy.node import Node from ros2_bridge.bridge import ROS2Bridge import numpy as np from sensor_msgs.msg import Image as ROS_Image From d2b78bb3d9df1c4906370c3b19dde91d30a95721 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:31:31 +0300 Subject: [PATCH 30/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 9f9ebb2efb..d640671276 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -29,7 +29,7 @@ class SyntheticDataGeneration(Node): - def __init__(self, input_image_topic="/usb_cam/image_raw", output_image_topic="/opendr/synthetic_facial_images", + def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/opendr/synthetic_facial_images", device="cuda"): """ Creates a ROS Node for SyntheticDataGeneration From fcf25fe4146c8836c1257cb28b4b2f9e6124649e Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:32:45 +0300 Subject: [PATCH 31/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index d640671276..c786e9cb80 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -35,9 +35,9 @@ def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/o Creates a ROS Node for SyntheticDataGeneration :param input_image_topic: Topic from which we are reading the input image :type input_image_topic: str - :param output_image_topic: Topic to which we are publishing the synthetic facial image (if None, we are not publishing - any image) - :type output_image_topic: str + :param output_rgb_image_topic: Topic to which we are publishing the synthetic facial image (if None, no image + is published) + :type output_rgb_image_topic: str :param device: device on which we are running eval ('cpu' or 'cuda') :type device: str """ From e29bab2d8f886863d09abdd20eb3ec272e648966 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:34:05 +0300 Subject: [PATCH 32/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index c786e9cb80..0008a43ba3 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -33,8 +33,8 @@ def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/o device="cuda"): """ Creates a ROS Node for SyntheticDataGeneration - :param input_image_topic: Topic from which we are reading the input image - :type input_image_topic: str + :param input_rgb_image_topic: Topic from which we are reading the input image + :type input_rgb_image_topic: str :param output_rgb_image_topic: Topic to which we are publishing the synthetic facial image (if None, no image is published) :type output_rgb_image_topic: str From 1d2fd741073d86a5e38e445ce7006a60f2161e93 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:36:46 +0300 Subject: [PATCH 33/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 0008a43ba3..b5fffe4953 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -46,7 +46,7 @@ def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/o self.image_publisher = self.create_publisher(output_image_topic, ROS_Image, queue_size=10) else: self.image_publisher = None - self.create_subscription(input_image_topic, ROS_Image, self.callback) + self.create_subscription(input_image_topic, ROS_Image, self.callback, 1) self.bridge = ROS2Bridge() self.ID = 0 From edf4ebf9e2b8b7137c15d76c251e92a0c8ca5c83 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:37:32 +0300 Subject: [PATCH 34/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index b5fffe4953..3091182c85 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -17,7 +17,7 @@ import torch import rclpy from rclpy.node import Node -from ros2_bridge.bridge import ROS2Bridge +from opendr_ros2_bridge import ROS2Bridge import numpy as np from sensor_msgs.msg import Image as ROS_Image from SyntheticDataGeneration import MultiviewDataGeneration From 6e7478ed13ac3a0b3813b03d98c6e8343ee0bfd5 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:45:24 +0300 Subject: [PATCH 35/82] Update package.xml --- projects/opendr_ws_2/src/data_generation/package.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/package.xml b/projects/opendr_ws_2/src/data_generation/package.xml index b5fce32684..9a712ee877 100644 --- a/projects/opendr_ws_2/src/data_generation/package.xml +++ b/projects/opendr_ws_2/src/data_generation/package.xml @@ -6,12 +6,20 @@ OpenDR ROS2 node for synthetic multiview facial image generation tefas Apache License v2.0 - + + rclcpp> + sensor_msgs + + rclpy + opendr_ros2_bridge + + ament_cmake + ament_copyright ament_flake8 ament_pep257 python3-pytest - + ament_python From 35d0d33485f0adc0939998add7db6b34eb112772 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 12 Sep 2022 16:57:49 +0300 Subject: [PATCH 36/82] Update synthetic_facial_generation.py --- .../synthetic_facial_generation.py | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 3091182c85..e96ac644a0 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -68,12 +68,14 @@ def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/o "", "results"), type=str, help='Give the path of results folder') - self.parser.add_argument('-val_yaw', default="10 20", nargs='+', type=str, help='yaw poses list between [-90,90]') + self.parser.add_argument('-val_yaw', default="10 20", nargs='+', + type=str, help='yaw poses list between [-90,90]') self.parser.add_argument('-val_pitch', default="30 40", nargs='+', type=str, help='pitch poses list between [-90,90] ') self.parser.add_argument('-f', '--files', nargs='+', help='image files paths fed into network, single or multiple images') - self.parser.add_argument('--show_flg', default='false', type=str2bool, help='whether show the visualization result') + self.parser.add_argument('--show_flg', default='false', type=str2bool, + help='whether show the visualization result') self.parser.add_argument('--dump_res', default='true', type=str2bool, help='whether write out the visualization image') self.parser.add_argument('--dump_vertex', default='false', type=str2bool, @@ -87,18 +89,25 @@ def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/o self.parser.add_argument('--dump_paf', default='true', type=str2bool) self.parser.add_argument('--paf_size', default=3, type=int, help='PAF feature kernel size') self.parser.add_argument('--dump_obj', default='true', type=str2bool) - self.parser.add_argument('--dlib_bbox', default='true', type=str2bool, help='whether use dlib to predict bbox') + self.parser.add_argument('--dlib_bbox', default='true', type=str2bool, + help='whether use dlib to predict bbox') self.parser.add_argument('--dlib_landmark', default='true', type=str2bool, help='whether use dlib landmark to crop image') self.parser.add_argument('-m', '--mode', default='gpu', type=str, help='gpu or cpu mode') self.parser.add_argument('--bbox_init', default='two', type=str, help='one|two: one-step bbox initialization or two-step') - self.parser.add_argument('--dump_2d_img', default='true', type=str2bool, help='whether to save 3d rendered image') - self.parser.add_argument('--dump_param', default='true', type=str2bool, help='whether to save param') - self.parser.add_argument('--dump_lmk', default='true', type=str2bool, help='whether to save landmarks') - self.parser.add_argument('--save_dir', default='./algorithm/DDFA/results', type=str, help='dir to save result') - self.parser.add_argument('--save_lmk_dir', default='./example', type=str, help='dir to save landmark result') - self.parser.add_argument('--img_list', default='./txt_name_batch.txt', type=str, help='test image list file') + self.parser.add_argument('--dump_2d_img', default='true', type=str2bool, + help='whether to save 3d rendered image') + self.parser.add_argument('--dump_param', default='true', type=str2bool, + help='whether to save param') + self.parser.add_argument('--dump_lmk', default='true', type=str2bool, + help='whether to save landmarks') + self.parser.add_argument('--save_dir', default='./algorithm/DDFA/results', + type=str, help='dir to save result') + self.parser.add_argument('--save_lmk_dir', default='./example', type=str, + help='dir to save landmark result') + self.parser.add_argument('--img_list', default='./txt_name_batch.txt', + type=str, help='test image list file') self.parser.add_argument('--rank', default=0, type=int, help='used when parallel run') self.parser.add_argument('--world_size', default=1, type=int, help='used when parallel run') self.parser.add_argument('--resume_idx', default=0, type=int) From fb6ce7a0a40d5163efd824997b8640a2a6aedcc2 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 13 Sep 2022 10:12:54 +0300 Subject: [PATCH 37/82] Update .github/workflows/tests_suite_develop.yml Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .github/workflows/tests_suite_develop.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests_suite_develop.yml b/.github/workflows/tests_suite_develop.yml index c826152349..89f963969f 100644 --- a/.github/workflows/tests_suite_develop.yml +++ b/.github/workflows/tests_suite_develop.yml @@ -184,8 +184,6 @@ jobs: - perception/speech_recognition - perception/skeleton_based_action_recognition - perception/semantic_segmentation - - perception/object_detection_2d - - perception/fall_detection - perception/object_detection_2d/centernet - perception/object_detection_2d/detr - perception/object_detection_2d/gem From 9ae937b1145359aefac4f2751ade62e7090836d9 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 13 Sep 2022 10:17:15 +0300 Subject: [PATCH 38/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index e96ac644a0..baa17daae4 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -15,15 +15,18 @@ import cv2 import torch +import os +import argparse +import numpy as np + import rclpy from rclpy.node import Node -from opendr_ros2_bridge import ROS2Bridge -import numpy as np + from sensor_msgs.msg import Image as ROS_Image -from SyntheticDataGeneration import MultiviewDataGeneration -import os -import argparse +from opendr_ros2_bridge import ROS2Bridge + from opendr.engine.data import Image +from SyntheticDataGeneration import MultiviewDataGeneration from algorithm.DDFA.utils.ddfa import str2bool From b453f7fd26dfedcb37b3d526a837e816269463f0 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Thu, 15 Sep 2022 14:30:56 +0300 Subject: [PATCH 39/82] Update synthetic_facial_generation.py --- .../synthetic_facial_generation.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index baa17daae4..afe04ac68b 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -38,7 +38,7 @@ def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/o Creates a ROS Node for SyntheticDataGeneration :param input_rgb_image_topic: Topic from which we are reading the input image :type input_rgb_image_topic: str - :param output_rgb_image_topic: Topic to which we are publishing the synthetic facial image (if None, no image + :param output_rgb_image_topic: Topic to which we are publishing the synthetic facial image (if None, no image is published) :type output_rgb_image_topic: str :param device: device on which we are running eval ('cpu' or 'cuda') @@ -71,13 +71,13 @@ def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/o "", "results"), type=str, help='Give the path of results folder') - self.parser.add_argument('-val_yaw', default="10 20", nargs='+', + self.parser.add_argument('-val_yaw', default="10 20", nargs='+', type=str, help='yaw poses list between [-90,90]') self.parser.add_argument('-val_pitch', default="30 40", nargs='+', type=str, help='pitch poses list between [-90,90] ') self.parser.add_argument('-f', '--files', nargs='+', help='image files paths fed into network, single or multiple images') - self.parser.add_argument('--show_flg', default='false', type=str2bool, + self.parser.add_argument('--show_flg', default='false', type=str2bool, help='whether show the visualization result') self.parser.add_argument('--dump_res', default='true', type=str2bool, help='whether write out the visualization image') @@ -92,24 +92,24 @@ def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/o self.parser.add_argument('--dump_paf', default='true', type=str2bool) self.parser.add_argument('--paf_size', default=3, type=int, help='PAF feature kernel size') self.parser.add_argument('--dump_obj', default='true', type=str2bool) - self.parser.add_argument('--dlib_bbox', default='true', type=str2bool, + self.parser.add_argument('--dlib_bbox', default='true', type=str2bool, help='whether use dlib to predict bbox') self.parser.add_argument('--dlib_landmark', default='true', type=str2bool, help='whether use dlib landmark to crop image') self.parser.add_argument('-m', '--mode', default='gpu', type=str, help='gpu or cpu mode') self.parser.add_argument('--bbox_init', default='two', type=str, help='one|two: one-step bbox initialization or two-step') - self.parser.add_argument('--dump_2d_img', default='true', type=str2bool, + self.parser.add_argument('--dump_2d_img', default='true', type=str2bool, help='whether to save 3d rendered image') - self.parser.add_argument('--dump_param', default='true', type=str2bool, + self.parser.add_argument('--dump_param', default='true', type=str2bool, help='whether to save param') - self.parser.add_argument('--dump_lmk', default='true', type=str2bool, + self.parser.add_argument('--dump_lmk', default='true', type=str2bool, help='whether to save landmarks') - self.parser.add_argument('--save_dir', default='./algorithm/DDFA/results', + self.parser.add_argument('--save_dir', default='./algorithm/DDFA/results', type=str, help='dir to save result') - self.parser.add_argument('--save_lmk_dir', default='./example', type=str, + self.parser.add_argument('--save_lmk_dir', default='./example', type=str, help='dir to save landmark result') - self.parser.add_argument('--img_list', default='./txt_name_batch.txt', + self.parser.add_argument('--img_list', default='./txt_name_batch.txt', type=str, help='test image list file') self.parser.add_argument('--rank', default=0, type=int, help='used when parallel run') self.parser.add_argument('--world_size', default=1, type=int, help='used when parallel run') From 37471a4d23e1460861d5ef5a362855b87a169608 Mon Sep 17 00:00:00 2001 From: ekakalet Date: Thu, 29 Sep 2022 16:47:58 +0300 Subject: [PATCH 40/82] ros2 --- .../synthetic_facial_generation.py | 197 ++++++++++-------- 1 file changed, 107 insertions(+), 90 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index baa17daae4..ff899164f9 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -23,98 +23,50 @@ from rclpy.node import Node from sensor_msgs.msg import Image as ROS_Image -from opendr_ros2_bridge import ROS2Bridge +from cv_bridge import CvBridge -from opendr.engine.data import Image -from SyntheticDataGeneration import MultiviewDataGeneration -from algorithm.DDFA.utils.ddfa import str2bool +from opendr.projects.data_generation.synthetic_multi_view_facial_image_generation.algorithm.DDFA.utils.ddfa \ + import str2bool +from opendr.src.opendr.engine.data import Image +from opendr.projects.data_generation.synthetic_multi_view_facial_image_generation.SyntheticDataGeneration \ + import MultiviewDataGeneration +from opendr_ros2_bridge import ROS2Bridge -class SyntheticDataGeneration(Node): +class Synthetic_Data_Generation(Node): - def __init__(self, input_rgb_image_topic="image_raw", output_rgb_image_topic="/opendr/synthetic_facial_images", - device="cuda"): + def __init__(self, args, input_rgb_image_topic="/image_raw", + output_rgb_image_topic="/opendr/synthetic_facial_images"): """ Creates a ROS Node for SyntheticDataGeneration :param input_rgb_image_topic: Topic from which we are reading the input image :type input_rgb_image_topic: str - :param output_rgb_image_topic: Topic to which we are publishing the synthetic facial image (if None, no image + :param output_rgb_image_topic: Topic to which we are publishing the synthetic facial image (if None, no image is published) :type output_rgb_image_topic: str :param device: device on which we are running eval ('cpu' or 'cuda') :type device: str """ - - if output_image_topic is not None: - self.image_publisher = self.create_publisher(output_image_topic, ROS_Image, queue_size=10) + super().__init__('synthetic_facial_image_generation_node') + if output_rgb_image_topic is not None: + self.image_publisher = self.create_publisher(ROS_Image, output_rgb_image_topic, 10) else: self.image_publisher = None - self.create_subscription(input_image_topic, ROS_Image, self.callback, 1) - self.bridge = ROS2Bridge() + self.create_subscription(ROS_Image, input_rgb_image_topic, self.callback, 1) + self._cv_bridge = CvBridge() self.ID = 0 + self.args = args + self.path_in = args.path_in + self.key = str(args.path_3ddfa + "/example/Images/") + self.key1 = str(args.path_3ddfa + "/example/") + self.key2 = str(args.path_3ddfa + "/results/") + self.save_path = args.save_path + self.val_yaw = args.val_yaw + self.val_pitch = args.val_pitch + self.device = args.device + # Initialize the SyntheticDataGeneration - self.parser = argparse.ArgumentParser() - self.parser.add_argument("-device", default="cuda", type=str, help="choose between cuda or cpu ") - self.parser.add_argument("-path_in", default=os.path.join("opendr_internal", "projects", - "data_generation", - "", - "demos", "imgs_input"), - type=str, help='Give the path of image folder') - self.parser.add_argument('-path_3ddfa', default=os.path.join("opendr_internal", "projects", - "data_generation", - "", - "algorithm", "DDFA"), - type=str, help='Give the path of DDFA folder') - self.parser.add_argument('-save_path', default=os.path.join("opendr_internal", "projects", - "data_generation", - "", - "results"), - type=str, help='Give the path of results folder') - self.parser.add_argument('-val_yaw', default="10 20", nargs='+', - type=str, help='yaw poses list between [-90,90]') - self.parser.add_argument('-val_pitch', default="30 40", nargs='+', type=str, - help='pitch poses list between [-90,90] ') - self.parser.add_argument('-f', '--files', nargs='+', - help='image files paths fed into network, single or multiple images') - self.parser.add_argument('--show_flg', default='false', type=str2bool, - help='whether show the visualization result') - self.parser.add_argument('--dump_res', default='true', type=str2bool, - help='whether write out the visualization image') - self.parser.add_argument('--dump_vertex', default='false', type=str2bool, - help='whether write out the dense face vertices to mat') - self.parser.add_argument('--dump_ply', default='true', type=str2bool) - self.parser.add_argument('--dump_pts', default='true', type=str2bool) - self.parser.add_argument('--dump_roi_box', default='false', type=str2bool) - self.parser.add_argument('--dump_pose', default='true', type=str2bool) - self.parser.add_argument('--dump_depth', default='true', type=str2bool) - self.parser.add_argument('--dump_pncc', default='true', type=str2bool) - self.parser.add_argument('--dump_paf', default='true', type=str2bool) - self.parser.add_argument('--paf_size', default=3, type=int, help='PAF feature kernel size') - self.parser.add_argument('--dump_obj', default='true', type=str2bool) - self.parser.add_argument('--dlib_bbox', default='true', type=str2bool, - help='whether use dlib to predict bbox') - self.parser.add_argument('--dlib_landmark', default='true', type=str2bool, - help='whether use dlib landmark to crop image') - self.parser.add_argument('-m', '--mode', default='gpu', type=str, help='gpu or cpu mode') - self.parser.add_argument('--bbox_init', default='two', type=str, - help='one|two: one-step bbox initialization or two-step') - self.parser.add_argument('--dump_2d_img', default='true', type=str2bool, - help='whether to save 3d rendered image') - self.parser.add_argument('--dump_param', default='true', type=str2bool, - help='whether to save param') - self.parser.add_argument('--dump_lmk', default='true', type=str2bool, - help='whether to save landmarks') - self.parser.add_argument('--save_dir', default='./algorithm/DDFA/results', - type=str, help='dir to save result') - self.parser.add_argument('--save_lmk_dir', default='./example', type=str, - help='dir to save landmark result') - self.parser.add_argument('--img_list', default='./txt_name_batch.txt', - type=str, help='test image list file') - self.parser.add_argument('--rank', default=0, type=int, help='used when parallel run') - self.parser.add_argument('--world_size', default=1, type=int, help='used when parallel run') - self.parser.add_argument('--resume_idx', default=0, type=int) - self.args = self.parser.parse_args() self.synthetic = MultiviewDataGeneration(self.args) def callback(self, data): @@ -126,19 +78,21 @@ def callback(self, data): # Convert sensor_msgs.msg.Image into OpenDR Image - image = self.bridge.from_ros_image(data) + cv_image = self._cv_bridge.imgmsg_to_cv2(data, desired_encoding="rgb8") + image = Image(np.asarray(cv_image, dtype=np.uint8)) self.ID = self.ID + 1 # Get an OpenCV image back - image = np.float32(image.numpy()) - name = str(f"{self.ID:02d}"+"_single.jpg") - cv2.imwrite(os.path.join(self.args.path_in, name), image) + image = cv2.cvtColor(image.opencv(), cv2.COLOR_RGBA2BGR) + name = str(f"{self.ID:02d}" + "_single.jpg") + print(image) + cv2.imwrite(os.path.join(self.path_in, name), image) - if (self.ID == 5): + if (self.ID == 10): # Run SyntheticDataGeneration self.synthetic.eval() self.ID = 0 # Annotate image and publish results - current_directory_path = os.path.join(self.args.save_path, str("/Documents_orig/")) + current_directory_path = os.path.join(self.save_path, str("/Documents_orig/")) for file in os.listdir(current_directory_path): name, ext = os.path.splitext(file) if ext == ".jpg": @@ -147,24 +101,87 @@ def callback(self, data): cv_image = cv2.cvtColor(cv_image, cv2.COLOR_BGR2RGB) if self.image_publisher is not None: image = Image(np.array(cv_image, dtype=np.uint8)) - message = self.bridge.to_ros_image(image, encoding="bgr8") + message = self.bridge.to_ros_image(image, encoding="rgb8") self.image_publisher.publish(message) - for f in os.listdir(self.args.path_in): - os.remove(os.path.join(self.args.path_in, f)) + for f in os.listdir(self.path_in): + os.remove(os.path.join(self.path_in, f)) def main(args=None): rclpy.init(args=args) + parser = argparse.ArgumentParser() + parser.add_argument("-i", "--input_rgb_image_topic", help="Topic name for input rgb image", + type=str, default="/image_raw") + parser.add_argument("-o", "--output_rgb_image_topic", help="Topic name for output annotated rgb image", + type=lambda value: value if value.lower() != "none" else None, + default="/opendr/synthetic_facial_images") + parser.add_argument("--device", help="Device to use (cpu, cuda)", type=str, default="cuda", choices=["cuda", "cpu"]) + parser.add_argument("--path_in", default=os.path.join("opendr", "projects", + "data_generation", + "synthetic_multi_view_facial_image_generation", + "demos", "imgs_input"), + type=str, help='Give the path of image folder') + parser.add_argument('--path_3ddfa', default=os.path.join("opendr", "projects", + "data_generation", + "synthetic_multi_view_facial_image_generation", + "algorithm", "DDFA"), + type=str, help='Give the path of DDFA folder') + parser.add_argument('--save_path', default=os.path.join("opendr", "projects", + "data_generation", + "synthetic_multi_view_facial_image_generation", + "results"), + type=str, help='Give the path of results folder') + parser.add_argument('--val_yaw', default="10 20", nargs='+', type=str, help='yaw poses list between [-90,90]') + parser.add_argument('--val_pitch', default="30 40", nargs='+', type=str, help='pitch poses list between [-90,90]') + parser.add_argument('-f', '--files', nargs='+', + help='image files paths fed into network, single or multiple images') + parser.add_argument('--show_flg', default='false', type=str2bool, help='whether show the visualization result') + parser.add_argument('--dump_res', default='true', type=str2bool, + help='whether write out the visualization image') + parser.add_argument('--dump_vertex', default='false', type=str2bool, + help='whether write out the dense face vertices to mat') + parser.add_argument('--dump_ply', default='true', type=str2bool) + parser.add_argument('--dump_pts', default='true', type=str2bool) + parser.add_argument('--dump_roi_box', default='false', type=str2bool) + parser.add_argument('--dump_pose', default='true', type=str2bool) + parser.add_argument('--dump_depth', default='true', type=str2bool) + parser.add_argument('--dump_pncc', default='true', type=str2bool) + parser.add_argument('--dump_paf', default='true', type=str2bool) + parser.add_argument('--paf_size', default=3, type=int, help='PAF feature kernel size') + parser.add_argument('--dump_obj', default='true', type=str2bool) + parser.add_argument('--dlib_bbox', default='true', type=str2bool, help='whether use dlib to predict bbox') + parser.add_argument('--dlib_landmark', default='true', type=str2bool, + help='whether use dlib landmark to crop image') + parser.add_argument('-m', '--mode', default='gpu', type=str, help='gpu or cpu mode') + parser.add_argument('--bbox_init', default='two', type=str, + help='one|two: one-step bbox initialization or two-step') + parser.add_argument('--dump_2d_img', default='true', type=str2bool, help='whether to save 3d rendered image') + parser.add_argument('--dump_param', default='true', type=str2bool, help='whether to save param') + parser.add_argument('--dump_lmk', default='true', type=str2bool, help='whether to save landmarks') + parser.add_argument('--save_dir', default='./algorithm/DDFA/results', type=str, help='dir to save result') + parser.add_argument('--save_lmk_dir', default='./example', type=str, help='dir to save landmark result') + parser.add_argument('--img_list', default='./txt_name_batch.txt', type=str, help='test image list file') + parser.add_argument('--rank', default=0, type=int, help='used when parallel run') + parser.add_argument('--world_size', default=1, type=int, help='used when parallel run') + parser.add_argument('--resume_idx', default=0, type=int) + args = parser.parse_args() + try: - if torch.cuda.is_available(): - print("GPU found.") - device = 'cuda' - else: + if args.device == "cuda" and torch.cuda.is_available(): + device = "cuda" + elif args.device == "cuda": print("GPU not found. Using CPU instead.") - device = 'cpu' + device = "cpu" + else: + print("Using CPU.") + device = "cpu" except: - device = 'cpu' - syntheticdatageneration_node = Synthetic_Data_Generation(device=device) + print("Using CPU.") + device = "cpu" + + syntheticdatageneration_node = Synthetic_Data_Generation(args=args, + input_rgb_image_topic=args.input_rgb_image_topic, + output_rgb_image_topic=args.output_rgb_image_topic) rclpy.spin(syntheticdatageneration_node) From 97aab4b0bcd69a1ffc025e82e8d72ee56fb996c9 Mon Sep 17 00:00:00 2001 From: ekakalet Date: Thu, 29 Sep 2022 17:08:28 +0300 Subject: [PATCH 41/82] ros2 --- .../data_generation/synthetic_facial_generation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index ff899164f9..2d36d69db2 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -30,7 +30,6 @@ from opendr.src.opendr.engine.data import Image from opendr.projects.data_generation.synthetic_multi_view_facial_image_generation.SyntheticDataGeneration \ import MultiviewDataGeneration -from opendr_ros2_bridge import ROS2Bridge class Synthetic_Data_Generation(Node): From b96f58d1ae0518cdf43790c777d5b7fad6bc4328 Mon Sep 17 00:00:00 2001 From: ekakalet Date: Thu, 29 Sep 2022 17:13:28 +0300 Subject: [PATCH 42/82] ros2 --- .../data_generation/synthetic_facial_generation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 2d36d69db2..d1330af3d1 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -54,7 +54,6 @@ def __init__(self, args, input_rgb_image_topic="/image_raw", self.create_subscription(ROS_Image, input_rgb_image_topic, self.callback, 1) self._cv_bridge = CvBridge() self.ID = 0 - self.args = args self.path_in = args.path_in self.key = str(args.path_3ddfa + "/example/Images/") From d10312e7b234bfb2a498453f60d4c5e6df07aca7 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 11 Oct 2022 15:55:44 +0300 Subject: [PATCH 43/82] Update README.md --- .../synthetic_multi_view_facial_image_generation/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/data_generation/synthetic_multi_view_facial_image_generation/README.md b/projects/data_generation/synthetic_multi_view_facial_image_generation/README.md index dce7a7de7d..c8a650489d 100644 --- a/projects/data_generation/synthetic_multi_view_facial_image_generation/README.md +++ b/projects/data_generation/synthetic_multi_view_facial_image_generation/README.md @@ -44,7 +44,7 @@ wget https://github.com/cleardusk/3DDFA/blob/master/models/phase1_wpdc_vdc.pth.t 1. Execute the one-step OPENDR function ```tool_synthetic_facial_generation.py``` specifying the input images folder, the output folder, the desired degrees (range -90 to 90) for generating the facial images in multiple view angles pitch and yaw as indicated in the command line: ```sh -python3 tool_synthetic_facial_generation.py -path_in ./demos/imgs_input/ -path_3ddfa ./algorithm/DDFA/ -save_path ./results -val_yaw 10 40 -val_pitch 10 30 -device cuda +python3 tool_synthetic_facial_generation.py -path_in ./demos/imgs_input/ -path_3ddfa ./algorithm/DDFA/ -save_path ./results -val_yaw 10, 40 -val_pitch 10, 30 -device cuda ``` 3. The results can be found in ```results/rs_model/example/```, where multi-view facial images are generated for every person in a respective folder. From f3a4db7747fcf5dc06cbfa4bcfe1877bf3b912b6 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:03:19 +0300 Subject: [PATCH 44/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index d1330af3d1..003b492e54 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -175,7 +175,7 @@ def main(args=None): device = "cpu" except: print("Using CPU.") - device = "cpu" + syntheticdatageneration_node = Synthetic_Data_Generation(args=args, input_rgb_image_topic=args.input_rgb_image_topic, From 59bd68355c5c3c19542e99b5f006684c6e6bb140 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:08:00 +0300 Subject: [PATCH 45/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 003b492e54..9cf1625b9c 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -175,7 +175,6 @@ def main(args=None): device = "cpu" except: print("Using CPU.") - syntheticdatageneration_node = Synthetic_Data_Generation(args=args, input_rgb_image_topic=args.input_rgb_image_topic, From ee7d9b65d637e5681443014fbce78ce86cd7d3a1 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:14:26 +0300 Subject: [PATCH 46/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 9cf1625b9c..bdd1d740dc 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -166,16 +166,15 @@ def main(args=None): try: if args.device == "cuda" and torch.cuda.is_available(): - device = "cuda" + print("GPU found.") elif args.device == "cuda": print("GPU not found. Using CPU instead.") - device = "cpu" else: print("Using CPU.") - device = "cpu" except: print("Using CPU.") - + + syntheticdatageneration_node = Synthetic_Data_Generation(args=args, input_rgb_image_topic=args.input_rgb_image_topic, output_rgb_image_topic=args.output_rgb_image_topic) From e769e97c238ee79f6233309791c7cd33445251e0 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:17:28 +0300 Subject: [PATCH 47/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index bdd1d740dc..6ca43f530e 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -173,8 +173,7 @@ def main(args=None): print("Using CPU.") except: print("Using CPU.") - - + syntheticdatageneration_node = Synthetic_Data_Generation(args=args, input_rgb_image_topic=args.input_rgb_image_topic, output_rgb_image_topic=args.output_rgb_image_topic) From fca0a2703ec0d68d96f13e4b7dd02cfd3016b24d Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:32:41 +0300 Subject: [PATCH 48/82] Update test_copyright.py --- projects/opendr_ws_2/src/data_generation/test/test_copyright.py | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py index 5c87e1e36d..3b1849b5a0 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py @@ -1,3 +1,4 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. from ament_copyright.main import main import pytest From f161407bfb90143b75f8d818522c1375bcc6060f Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:32:59 +0300 Subject: [PATCH 49/82] Update test_flake8.py --- projects/opendr_ws_2/src/data_generation/test/test_flake8.py | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py index 63b55be7a9..0b94dfa050 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py @@ -1,3 +1,4 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. from ament_flake8.main import main_with_errors import pytest From 4a59ebfb43bc91a3bcdc03ed27979d57a07bd2e4 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:33:37 +0300 Subject: [PATCH 50/82] Update test_pep257.py --- projects/opendr_ws_2/src/data_generation/test/test_pep257.py | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py index 4795382c6b..a72b55af3f 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py @@ -1,3 +1,4 @@ +# Copyright 2017 Open Source Robotics Foundation, Inc. from ament_pep257.main import main import pytest From 245780636e8c0ade5c657e24cb69e5bd8eeff303 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 17 Oct 2022 16:41:51 +0300 Subject: [PATCH 51/82] Update test_license.py --- tests/test_license.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_license.py b/tests/test_license.py index bc15711c03..3b7da5ed88 100755 --- a/tests/test_license.py +++ b/tests/test_license.py @@ -107,7 +107,7 @@ def setUp(self): 'src/opendr/perception/facial_expression_recognition/landmark_based_facial_expression_recognition', 'projects/opendr_ws_2/src/opendr_perception/test', 'projects/opendr_ws_2/src/opendr_ros2_bridge/test', - 'projects/opendr_ws_2/src/data_generation/test/', + 'projects/opendr_ws_2/src/data_generation/test', ] skippedFilePaths = [ From 3354d35b658eced07d683bb3959e4f2371313bbd Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Wed, 19 Oct 2022 15:01:00 +0300 Subject: [PATCH 52/82] Update test_license.py --- tests/test_license.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_license.py b/tests/test_license.py index 82675502cf..3015a42cdf 100644 --- a/tests/test_license.py +++ b/tests/test_license.py @@ -123,7 +123,7 @@ def setUp(self): 'src/opendr/perception/multimodal_human_centric/audiovisual_emotion_learner/algorithm/transformer_timm.py', 'src/opendr/perception/multimodal_human_centric/audiovisual_emotion_learner/algorithm/utils.py', 'projects/opendr_ws_2/src/opendr_perception/setup.py', - 'projects/opendr_ws_2/src/opendr_ros2_bridge/setup.py',n + 'projects/opendr_ws_2/src/opendr_ros2_bridge/setup.py', 'projects/opendr_ws_2/src/data_generation/setup.py', 'projects/opendr_ws_2/src/opendr_simulation/setup.py', From 814abf0efe73bec2351471d1c7ba3f1d7442a2af Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:44:31 +0300 Subject: [PATCH 53/82] Update Dockerfile-cuda Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- Dockerfile-cuda | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile-cuda b/Dockerfile-cuda index e70431d7b9..2a57bc5b91 100644 --- a/Dockerfile-cuda +++ b/Dockerfile-cuda @@ -6,8 +6,6 @@ ARG branch=develop ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu$(cat /etc/os-release | grep VERSION_ID | awk '{print substr($0,13,5)}' | awk -F'.' '{print $1$2}')/x86_64/3bf863cc.pub -ARG branch=develop - # Install dependencies RUN apt-get update && \ apt-get --yes install git sudo apt-utils && \ From eec327930963de81e51d24e00f24fab9c2b03edd Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:54:37 +0300 Subject: [PATCH 54/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 6ca43f530e..36224e96cb 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -32,7 +32,7 @@ import MultiviewDataGeneration -class Synthetic_Data_Generation(Node): +class SyntheticDataGeneration(Node): def __init__(self, args, input_rgb_image_topic="/image_raw", output_rgb_image_topic="/opendr/synthetic_facial_images"): From 6fff4c64bd61388a6e64f1ce6292febaf0cfa5ee Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:55:08 +0300 Subject: [PATCH 55/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 36224e96cb..4443ee6aec 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -43,8 +43,6 @@ def __init__(self, args, input_rgb_image_topic="/image_raw", :param output_rgb_image_topic: Topic to which we are publishing the synthetic facial image (if None, no image is published) :type output_rgb_image_topic: str - :param device: device on which we are running eval ('cpu' or 'cuda') - :type device: str """ super().__init__('synthetic_facial_image_generation_node') if output_rgb_image_topic is not None: From b98cfe8084b5859e5e1737ee32279b5d20e6c4d4 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:55:34 +0300 Subject: [PATCH 56/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 4443ee6aec..f50032aee2 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -80,7 +80,6 @@ def callback(self, data): # Get an OpenCV image back image = cv2.cvtColor(image.opencv(), cv2.COLOR_RGBA2BGR) name = str(f"{self.ID:02d}" + "_single.jpg") - print(image) cv2.imwrite(os.path.join(self.path_in, name), image) if (self.ID == 10): From 94126bec4c4371a3aafc1656e29b4f7d9952e91a Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:55:54 +0300 Subject: [PATCH 57/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index f50032aee2..9e674b877b 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -82,7 +82,7 @@ def callback(self, data): name = str(f"{self.ID:02d}" + "_single.jpg") cv2.imwrite(os.path.join(self.path_in, name), image) - if (self.ID == 10): + if self.ID == 10: # Run SyntheticDataGeneration self.synthetic.eval() self.ID = 0 From 91d2604bbf7ca83d5a11e9132f58f481ffc4bd78 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:56:51 +0300 Subject: [PATCH 58/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 9e674b877b..0e4f43d654 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -14,7 +14,6 @@ # limitations under the License. import cv2 -import torch import os import argparse import numpy as np From 74d78500587c2c5ea63c7401772ca5d50083a7ce Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:57:17 +0300 Subject: [PATCH 59/82] Update projects/opendr_ws_2/src/data_generation/test/test_copyright.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../src/data_generation/test/test_copyright.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py index 3b1849b5a0..cc8ff03f79 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_copyright.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_copyright.py @@ -1,4 +1,17 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from ament_copyright.main import main import pytest From b4b4dc2889c1e0700dc007abc9b4917806ad73e0 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:57:29 +0300 Subject: [PATCH 60/82] Update projects/opendr_ws_2/src/data_generation/test/test_flake8.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../src/data_generation/test/test_flake8.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py index 0b94dfa050..18bd9331ea 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_flake8.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_flake8.py @@ -1,4 +1,17 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from ament_flake8.main import main_with_errors import pytest From 4c4149ef72d5dd6c5e4980b7117540ca250d2af7 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:57:49 +0300 Subject: [PATCH 61/82] Update projects/opendr_ws_2/src/data_generation/test/test_pep257.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../src/data_generation/test/test_pep257.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py index a72b55af3f..b234a3840f 100644 --- a/projects/opendr_ws_2/src/data_generation/test/test_pep257.py +++ b/projects/opendr_ws_2/src/data_generation/test/test_pep257.py @@ -1,4 +1,17 @@ -# Copyright 2017 Open Source Robotics Foundation, Inc. +# Copyright 2015 Open Source Robotics Foundation, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from ament_pep257.main import main import pytest From 265189faf1bd0a7ed12b2e39478e655a8a357df7 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:58:05 +0300 Subject: [PATCH 62/82] Update tests/test_license.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- tests/test_license.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_license.py b/tests/test_license.py index 3015a42cdf..ece6d5bb35 100644 --- a/tests/test_license.py +++ b/tests/test_license.py @@ -126,7 +126,6 @@ def setUp(self): 'projects/opendr_ws_2/src/opendr_ros2_bridge/setup.py', 'projects/opendr_ws_2/src/data_generation/setup.py', 'projects/opendr_ws_2/src/opendr_simulation/setup.py', - ] skippedDirectories = [ From b8151d6f26253426a5143d2a7b76579e3d04fe3a Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:58:49 +0300 Subject: [PATCH 63/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 0e4f43d654..106c3a55bb 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -109,7 +109,6 @@ def main(args=None): parser.add_argument("-o", "--output_rgb_image_topic", help="Topic name for output annotated rgb image", type=lambda value: value if value.lower() != "none" else None, default="/opendr/synthetic_facial_images") - parser.add_argument("--device", help="Device to use (cpu, cuda)", type=str, default="cuda", choices=["cuda", "cpu"]) parser.add_argument("--path_in", default=os.path.join("opendr", "projects", "data_generation", "synthetic_multi_view_facial_image_generation", From d62400dc5beb12f4fbfbfebca4ac266064a676b9 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 10:59:10 +0300 Subject: [PATCH 64/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 106c3a55bb..3d775c416e 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -159,15 +159,6 @@ def main(args=None): parser.add_argument('--resume_idx', default=0, type=int) args = parser.parse_args() - try: - if args.device == "cuda" and torch.cuda.is_available(): - print("GPU found.") - elif args.device == "cuda": - print("GPU not found. Using CPU instead.") - else: - print("Using CPU.") - except: - print("Using CPU.") syntheticdatageneration_node = Synthetic_Data_Generation(args=args, input_rgb_image_topic=args.input_rgb_image_topic, From 6f5508bd3a31a49e062aa9470d7a0b9a4415350e Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:01:40 +0300 Subject: [PATCH 65/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 3d775c416e..acdde958d2 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -26,7 +26,7 @@ from opendr.projects.data_generation.synthetic_multi_view_facial_image_generation.algorithm.DDFA.utils.ddfa \ import str2bool -from opendr.src.opendr.engine.data import Image +from opendr.engine.data import Image from opendr.projects.data_generation.synthetic_multi_view_facial_image_generation.SyntheticDataGeneration \ import MultiviewDataGeneration From b71001d448710f7f71261d0235c13385f2f0b7c8 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:02:06 +0300 Subject: [PATCH 66/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index acdde958d2..4db818a8ed 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -24,7 +24,7 @@ from sensor_msgs.msg import Image as ROS_Image from cv_bridge import CvBridge -from opendr.projects.data_generation.synthetic_multi_view_facial_image_generation.algorithm.DDFA.utils.ddfa \ +from opendr.projects.python.simulation.synthetic_multi_view_facial_image_generation.algorithm.DDFA.utils.ddfa \ import str2bool from opendr.engine.data import Image from opendr.projects.data_generation.synthetic_multi_view_facial_image_generation.SyntheticDataGeneration \ From 778daa948436579c88560bdc16f98227e6811580 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:02:39 +0300 Subject: [PATCH 67/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 4db818a8ed..606e919310 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -27,7 +27,7 @@ from opendr.projects.python.simulation.synthetic_multi_view_facial_image_generation.algorithm.DDFA.utils.ddfa \ import str2bool from opendr.engine.data import Image -from opendr.projects.data_generation.synthetic_multi_view_facial_image_generation.SyntheticDataGeneration \ +from opendr.projects.python.simulation.synthetic_multi_view_facial_image_generation.SyntheticDataGeneration \ import MultiviewDataGeneration From ec514f2f784701c663b656ef3d08d4e651557214 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:03:13 +0300 Subject: [PATCH 68/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 606e919310..7d01cf7ae6 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -160,11 +160,12 @@ def main(args=None): args = parser.parse_args() - syntheticdatageneration_node = Synthetic_Data_Generation(args=args, - input_rgb_image_topic=args.input_rgb_image_topic, + synthetic_data_generation_node = SyntheticDataGeneration(args=args, + input_rgb_image_topic=args.input_rgb_image_topic, output_rgb_image_topic=args.output_rgb_image_topic) - rclpy.spin(syntheticdatageneration_node) + rclpy.spin(synthetic_data_generation_node) + # Destroy the node explicitly # (optional - otherwise it will be done automatically From f6e676195c95ef1cdbe359b25967331b9448f89a Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:03:38 +0300 Subject: [PATCH 69/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 7d01cf7ae6..7920a42fd4 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -170,7 +170,7 @@ def main(args=None): # Destroy the node explicitly # (optional - otherwise it will be done automatically # when the garbage collector destroys the node object) - syntheticdatageneration_node.destroy_node() + synthetic_data_generation_node.destroy_node() rclpy.shutdown() From 86b0567c89d492c2ac8d5dee72a57857488f2e59 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:04:07 +0300 Subject: [PATCH 70/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 7920a42fd4..0c89f767e2 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -107,8 +107,7 @@ def main(args=None): parser.add_argument("-i", "--input_rgb_image_topic", help="Topic name for input rgb image", type=str, default="/image_raw") parser.add_argument("-o", "--output_rgb_image_topic", help="Topic name for output annotated rgb image", - type=lambda value: value if value.lower() != "none" else None, - default="/opendr/synthetic_facial_images") + type=str, default="/opendr/synthetic_facial_images") parser.add_argument("--path_in", default=os.path.join("opendr", "projects", "data_generation", "synthetic_multi_view_facial_image_generation", From 2f2ea69a11d18890dccd141b6e435eaf3a308958 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:04:35 +0300 Subject: [PATCH 71/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 0c89f767e2..34431065f1 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -44,10 +44,7 @@ def __init__(self, args, input_rgb_image_topic="/image_raw", :type output_rgb_image_topic: str """ super().__init__('synthetic_facial_image_generation_node') - if output_rgb_image_topic is not None: - self.image_publisher = self.create_publisher(ROS_Image, output_rgb_image_topic, 10) - else: - self.image_publisher = None + self.image_publisher = self.create_publisher(ROS_Image, output_rgb_image_topic, 10) self.create_subscription(ROS_Image, input_rgb_image_topic, self.callback, 1) self._cv_bridge = CvBridge() self.ID = 0 From cca077a838daf844fcedd5eb000f646e9cf3f489 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:07:36 +0300 Subject: [PATCH 72/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 34431065f1..383b421486 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -31,7 +31,7 @@ import MultiviewDataGeneration -class SyntheticDataGeneration(Node): +class SyntheticDataGenerator(Node): def __init__(self, args, input_rgb_image_topic="/image_raw", output_rgb_image_topic="/opendr/synthetic_facial_images"): @@ -156,7 +156,7 @@ def main(args=None): args = parser.parse_args() - synthetic_data_generation_node = SyntheticDataGeneration(args=args, + synthetic_data_generation_node = SyntheticDataGenerator(args=args, input_rgb_image_topic=args.input_rgb_image_topic, output_rgb_image_topic=args.output_rgb_image_topic) From fafe063f73b3134c98abd17c661cb6f0f04ab5f1 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:22:10 +0300 Subject: [PATCH 73/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 383b421486..f5a9ae3657 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -122,6 +122,7 @@ def main(args=None): type=str, help='Give the path of results folder') parser.add_argument('--val_yaw', default="10 20", nargs='+', type=str, help='yaw poses list between [-90,90]') parser.add_argument('--val_pitch', default="30 40", nargs='+', type=str, help='pitch poses list between [-90,90]') + parser.add_argument("--device", default="cuda", type=str, help="choose between cuda or cpu ") parser.add_argument('-f', '--files', nargs='+', help='image files paths fed into network, single or multiple images') parser.add_argument('--show_flg', default='false', type=str2bool, help='whether show the visualization result') From f1cd8f65b182061a57622a44394ec629f4936e06 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Tue, 25 Oct 2022 11:27:02 +0300 Subject: [PATCH 74/82] Update synthetic_facial_generation.py --- .../data_generation/synthetic_facial_generation.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index f5a9ae3657..0c83d8fffd 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -156,20 +156,17 @@ def main(args=None): parser.add_argument('--resume_idx', default=0, type=int) args = parser.parse_args() - - synthetic_data_generation_node = SyntheticDataGenerator(args=args, - input_rgb_image_topic=args.input_rgb_image_topic, - output_rgb_image_topic=args.output_rgb_image_topic) + synthetic_data_generation_node = SyntheticDataGenerator(args=args, + input_rgb_image_topic=args.input_rgb_image_topic, + output_rgb_image_topic=args.output_rgb_image_topic) rclpy.spin(synthetic_data_generation_node) - # Destroy the node explicitly # (optional - otherwise it will be done automatically # when the garbage collector destroys the node object) synthetic_data_generation_node.destroy_node() rclpy.shutdown() - if __name__ == '__main__': main() From 849d1dc1610d3c53949facbdd4a2c9af627d108b Mon Sep 17 00:00:00 2001 From: ekakalet Date: Thu, 3 Nov 2022 09:25:12 +0200 Subject: [PATCH 75/82] new updates --- .../data_generation/synthetic_facial_generation.py | 2 +- .../SyntheticDataGeneration.py | 6 +++--- .../algorithm/Rotate_and_Render/options/base_options.py | 4 ++-- .../algorithm/Rotate_and_Render/test_multipose.py | 2 +- src/opendr/engine/data.py | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index 0c83d8fffd..eaa05f63ab 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -26,7 +26,7 @@ from opendr.projects.python.simulation.synthetic_multi_view_facial_image_generation.algorithm.DDFA.utils.ddfa \ import str2bool -from opendr.engine.data import Image +from opendr.src.opendr.engine.data import Image from opendr.projects.python.simulation.synthetic_multi_view_facial_image_generation.SyntheticDataGeneration \ import MultiviewDataGeneration diff --git a/projects/python/simulation/synthetic_multi_view_facial_image_generation/SyntheticDataGeneration.py b/projects/python/simulation/synthetic_multi_view_facial_image_generation/SyntheticDataGeneration.py index 4df8e55fff..59e114a64c 100644 --- a/projects/python/simulation/synthetic_multi_view_facial_image_generation/SyntheticDataGeneration.py +++ b/projects/python/simulation/synthetic_multi_view_facial_image_generation/SyntheticDataGeneration.py @@ -40,9 +40,9 @@ from shutil import copyfile import cv2 import os -from algorithm.DDFA import preprocessing_1 -from algorithm.DDFA import preprocessing_2 -from algorithm.Rotate_and_Render import test_multipose +from .algorithm.DDFA import preprocessing_1 +from .algorithm.DDFA import preprocessing_2 +from .algorithm.Rotate_and_Render import test_multipose class MultiviewDataGeneration(): diff --git a/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/options/base_options.py b/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/options/base_options.py index 8528a58620..8bd14494e7 100644 --- a/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/options/base_options.py +++ b/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/options/base_options.py @@ -4,8 +4,8 @@ import os from ..util import util import torch -from algorithm.Rotate_and_Render import models -from algorithm.Rotate_and_Render import data +from .. import models +from .. import data import pickle __all__ = ['math'] diff --git a/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/test_multipose.py b/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/test_multipose.py index 8e8bf09b58..d18a1c48ba 100644 --- a/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/test_multipose.py +++ b/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/test_multipose.py @@ -14,7 +14,7 @@ import torch import math from .models.networks.rotate_render import TestRender -from algorithm.Rotate_and_Render.data import dataset_info +from .data import dataset_info multiprocessing.set_start_method('spawn', force=True) __all__ = ['dataset_info'] diff --git a/src/opendr/engine/data.py b/src/opendr/engine/data.py index 667027169c..13077b4f89 100644 --- a/src/opendr/engine/data.py +++ b/src/opendr/engine/data.py @@ -15,7 +15,7 @@ from pathlib import Path import cv2 from abc import ABC, abstractmethod -from opendr.engine.target import BoundingBoxList +from opendr.src.opendr.engine.target import BoundingBoxList import numpy as np import torch from typing import Union From ce4530d92148e0af42b7517376c81711f586bfcd Mon Sep 17 00:00:00 2001 From: ekakalet Date: Thu, 3 Nov 2022 09:26:35 +0200 Subject: [PATCH 76/82] updates --- .../opendr_ros2_bridge/bridge.py | 8 +++++--- .../models/networks/__init__.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py b/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py index 3c90ffe701..cc67bd9654 100644 --- a/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py +++ b/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py @@ -13,8 +13,8 @@ # limitations under the License. import numpy as np -from opendr.engine.data import Image -from opendr.engine.target import Pose, BoundingBox, BoundingBoxList, Category +from opendr.src.opendr.engine.data import Image +from opendr.src.opendr.engine.target import Pose, BoundingBox, BoundingBoxList, Category from cv_bridge import CvBridge from std_msgs.msg import String, ColorRGBA, Header @@ -23,7 +23,9 @@ Classification2D from shape_msgs.msg import Mesh, MeshTriangle from geometry_msgs.msg import Point, Pose2D -from opendr_ros2_messages.msg import OpenDRPose2D, OpenDRPose2DKeypoint, OpenDRPose3D, OpenDRPose3DKeypoint +from ...opendr_ros2_messages.msg import OpenDRPose2D, OpenDRPose2DKeypoint, OpenDRPose3D, OpenDRPose3DKeypoint + + class ROS2Bridge: diff --git a/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/models/networks/__init__.py b/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/models/networks/__init__.py index 91e0febc81..36314edf6e 100644 --- a/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/models/networks/__init__.py +++ b/projects/python/simulation/synthetic_multi_view_facial_image_generation/algorithm/Rotate_and_Render/models/networks/__init__.py @@ -1,18 +1,18 @@ import torch -from algorithm.Rotate_and_Render.models.networks.base_network import BaseNetwork -from algorithm.Rotate_and_Render.models.networks import loss -from algorithm.Rotate_and_Render.models.networks import discriminator -from algorithm.Rotate_and_Render.models.networks import generator -from algorithm.Rotate_and_Render.models.networks import encoder -from algorithm.Rotate_and_Render.models.networks.render import Render -import algorithm.Rotate_and_Render.util.util as util +from .base_network import BaseNetwork +from . import loss +from . import discriminator +from . import generator +from . import encoder +from .render import Render +from ...util.util import find_class_in_module __all__ = ['loss', 'discriminator', 'generator', 'encoder', 'Render'] def find_network_using_name(target_network_name, filename): target_class_name = target_network_name + filename module_name = 'algorithm.Rotate_and_Render.models.networks.' + filename - network = util.find_class_in_module(target_class_name, module_name) + network = find_class_in_module(target_class_name, module_name) assert issubclass(network, BaseNetwork), \ "Class %s should be a subclass of BaseNetwork" % network From 09cbcde0d1a43f1c55a0f21b627bad1062880b2c Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Thu, 3 Nov 2022 09:38:58 +0200 Subject: [PATCH 77/82] Update bridge.py --- .../src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py b/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py index 53b81e306a..a2b14f4cfd 100644 --- a/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py +++ b/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py @@ -27,8 +27,6 @@ from ...opendr_ros2_messages.msg import OpenDRPose2D, OpenDRPose2DKeypoint, OpenDRPose3D, OpenDRPose3DKeypoint - - class ROS2Bridge: """ This class provides an interface to convert OpenDR data types and targets into ROS2-compatible ones similar From a18b0ce04499af3612bda2b8c44d725682357030 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Thu, 3 Nov 2022 10:34:01 +0200 Subject: [PATCH 78/82] Update README.md From da744e3a7cd1eb04ba521f96045b21bd4fd9095a Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Thu, 3 Nov 2022 17:08:49 +0200 Subject: [PATCH 79/82] Update data.py --- src/opendr/engine/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opendr/engine/data.py b/src/opendr/engine/data.py index 13077b4f89..667027169c 100644 --- a/src/opendr/engine/data.py +++ b/src/opendr/engine/data.py @@ -15,7 +15,7 @@ from pathlib import Path import cv2 from abc import ABC, abstractmethod -from opendr.src.opendr.engine.target import BoundingBoxList +from opendr.engine.target import BoundingBoxList import numpy as np import torch from typing import Union From 43fad6e5d8e50a3497d80fe892a58ec2f496731d Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 7 Nov 2022 14:20:16 +0200 Subject: [PATCH 80/82] Update projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py b/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py index a2b14f4cfd..8299f58b33 100644 --- a/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py +++ b/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py @@ -16,7 +16,6 @@ from opendr.engine.data import Image, Timeseries from opendr.engine.target import Pose, BoundingBox, BoundingBoxList, Category - from cv_bridge import CvBridge from std_msgs.msg import String, ColorRGBA, Header from sensor_msgs.msg import Image as ImageMsg From e5a4d67c9678c3772d76fb8c582e5f064480e861 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 7 Nov 2022 14:21:23 +0200 Subject: [PATCH 81/82] Update projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py b/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py index 8299f58b33..5ba6b84ce5 100644 --- a/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py +++ b/projects/opendr_ws_2/src/opendr_ros2_bridge/opendr_ros2_bridge/bridge.py @@ -23,7 +23,7 @@ Classification2D from shape_msgs.msg import Mesh, MeshTriangle from geometry_msgs.msg import Point, Pose2D -from ...opendr_ros2_messages.msg import OpenDRPose2D, OpenDRPose2DKeypoint, OpenDRPose3D, OpenDRPose3DKeypoint +from opendr_ros2_messages.msg import OpenDRPose2D, OpenDRPose2DKeypoint, OpenDRPose3D, OpenDRPose3DKeypoint class ROS2Bridge: From c2c1f0ed7de59eedfb82461bc8c540e3b3676846 Mon Sep 17 00:00:00 2001 From: ekakalet <63847549+ekakalet@users.noreply.github.com> Date: Mon, 7 Nov 2022 14:21:37 +0200 Subject: [PATCH 82/82] Update projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py Co-authored-by: Kostas Tsampazis <27914645+tsampazk@users.noreply.github.com> --- .../data_generation/synthetic_facial_generation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py index eaa05f63ab..a32b925c03 100644 --- a/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py +++ b/projects/opendr_ws_2/src/data_generation/data_generation/synthetic_facial_generation.py @@ -168,5 +168,6 @@ def main(args=None): synthetic_data_generation_node.destroy_node() rclpy.shutdown() + if __name__ == '__main__': main()