Code Monkey home page Code Monkey logo

workshop-icra-2022-cloth-keypoints's Introduction

Learning Keypoints from Synthetic Data

for Robotic Cloth Folding

Thomas Lips, Victor-Louis De Gusseme, Francis wyffels
AI and Robotics Lab (AIRO) , Ghent University
2nd workshop on Representing and Manipulating Deformable Objects (RMDO)
IEEE International Conference on Robotics and Automation (ICRA), 2022

Paper | Poster | Spotlight Talk | Technical Video

In this work we learn to detect the corners of cloth items. We use procedural data generation to train a convolutional neural network from synthetic data, enabling low-cost data collection. We evaluate the zero-shot performance of this network on a unimanual robot setup for folding towels and find that the grasp and fold success rates are 77% and 53%, respectively. We conclude that learning keypoint detectors from synthetic data for such tasks is a promising research direction, discuss some failures and relate them to future work.


The codebase has 3 main components:

Procedural Data Generation

Keypoint Detection

Robot Folding

We also provide the pretrained weights and all training logs.

Data Generation

To generate synthetic images of unfolded cloths, we make use of Blender, version 3.0.1 Additionally, we use the excellent BlenderProc library and our own Blender-toolbox. The pipeline is shown in the figure below, for more details we refer to the paper.

Local Installation

  • run cd data-generation && bash setup.sh to install blender and the dependencies, as well as to download all the assets (might take a while).

Data generation

  • to create a scene, run blender-3.0.1-linux-x64/./blender --python data-generation/towel/towel/generate_towel_scene.py in the data-generation folder of this repository. Blender will now open and you should see the scene.
  • to generate the entire dataset used in this work, run /blender-3.0.1-linux-x64/./blender --python data-generation/towel/towel/generate_dataset.py -- --amount_of_samples 30000 --resolution 256 --start_seed 0. By default the dataset will be created in home/datasets but this can be changed if desired.

Keypoint Detection

The keypoint detection code can be found here: https://github.com/tlpss/keypoint-detection

Local Installation

  • git clone the repo at the specific commit using git clone https://github.com/tlpss/keypoint-detection && git checkout c793f3cf6d803d942054a36ae9b44c410cffa2b3 in the keypoints folder.
  • Follow the instructions at https://github.com/tlpss/keypoint-detection to install the dependencies.

CNN

  • To train on the dataset created: python /keypoints/keypoint-detection/keypoint_detection/train/train.py --ap_epoch_freq=5 --ap_epoch_start=5 --auto_select_gpus=True --backbone_type=Unet --batch_size=64 --early_stopping_relative_threshold=-0.01 --gpus=1 --heatmap_sigma=2 --image_dataset_path=<path-to-dataset> --json_dataset_path=<path-to-dataset>/dataset.json --keypoint_channel_max_keypoints=4 --keypoint_channels=corner_keypoints_visible --learning_rate=0.0003 --log_every_n_steps=20 --lr_scheduler_relative_threshold=0.005 --max_epochs=16 --maximal_gt_keypoint_pixel_distances="2 4" --minimal_keypoint_extraction_pixel_distance=30 --n_channels=32 --n_downsampling_layers=2 --n_resnet_blocks=16 --num_sanity_val_steps=1 --num_workers=4 --precision=32 --validation_split_ratio=0.1 --wandb_entity <your-wandb-profile>
  • All training details, as well as the model checkpoints can be found at https://wandb.ai/tlips/icra-2022-workshop/runs/2qand21y?workspace=user-tlips.
  • To use the trained model for inference, see below.

Robot

Local installation

  • This work uses a UR3e, ZED2i and Robotiq-2F85 gripper. If you have different hardware, you will need to handpick the relevant parts of the code in the robot/ folder.
  • print 2 fingers using Flexfill-98 TPU filament. The .stl file can be found under static/cad/
  • pip install opencv2: pip install opencv-contrib-python==4.5.5.64 in the conda environment of the keypoint detection code
  • clone the unreleased dependencies using vcs import robot < robot/dependencies.repos
  • pip install them in the same python environment as the keypoint detection code

Robotic Folding

  • determine your camera extrinsics using an Aruco marker and the marker_pose_to_pickle.py file, this will create a marker.pickle file.
  • Measure the position of your marker to the robot base frame manually and update the code at line 11 of robot/robot_script.py. Orientations are not supported so make sure to allign the marker to the base frame of the robot.
  • to manually mark the keypoints (to test the trajectories): python robot/manual_keypoints.py
  • to detect the keypoints using the pretrained weights (model.ckpt) and exectute the fold: python robot/detect_keypoints_and_fold.py

All images from the evaluation can be found here.

Citation

@inproceedings{lips2022synthkeypoints,
  title={Learning Keypoints from Synthetic Data for Robotic Cloth Folding},
  author={Lips, Thomas and De Gusseme, Victor-Louis and others},
  journal={2nd workshop on Representing and Manipulating Deformable Objects - ICRA},
  year={2022}
}

workshop-icra-2022-cloth-keypoints's People

Contributors

pre-commit-ci[bot] avatar tlpss avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

workshop-icra-2022-cloth-keypoints's Issues

About bpy

When I was downloading to import bpy, it failed. Tried many times, such as changing the python version to 3.7, but it still didn't work.
Uploading 2023-11-07 11-24-09屏幕截图.png…

About keypoint detection module

Hi, guys, when I ran the code bash test/integration_test.sh in my computer for keypoint-detection, I encountered the following problem:

File "/home/nkjx/cloth-fold/keypoints/keypoint-detection/keypoint_detection/train/train.py", line 115, in <module> main(hparams) File "/home/nkjx/cloth-fold/keypoints/keypoint-detection/keypoint_detection/train/train.py", line 60, in main trainer.fit(model, data_module) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 579, in fit call._call_and_handle_interrupt( File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/trainer/call.py", line 38, in _call_and_handle_interrupt return trainer_fn(*args, **kwargs) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 621, in _fit_impl self._run(model, ckpt_path=self.ckpt_path) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1058, in _run results = self._run_stage() File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1137, in _run_stage self._run_train() File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1160, in _run_train self.fit_loop.run() File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/loops/loop.py", line 200, in run self.on_advance_end() File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/loops/fit_loop.py", line 295, in on_advance_end self.trainer._call_callback_hooks("on_train_epoch_end") File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/trainer/trainer.py", line 1340, in _call_callback_hooks fn(self, self.lightning_module, *args, **kwargs) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/callbacks/model_checkpoint.py", line 312, in on_train_epoch_end self._save_topk_checkpoint(trainer, monitor_candidates) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/callbacks/model_checkpoint.py", line 369, in _save_topk_checkpoint self._save_monitor_checkpoint(trainer, monitor_candidates) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/callbacks/model_checkpoint.py", line 652, in _save_monitor_checkpoint self._update_best_and_save(current, trainer, monitor_candidates) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/callbacks/model_checkpoint.py", line 703, in _update_best_and_save self._save_checkpoint(trainer, filepath) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/callbacks/model_checkpoint.py", line 381, in _save_checkpoint logger.after_save_checkpoint(proxy(self)) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/loggers/wandb.py", line 515, in after_save_checkpoint self._scan_and_log_checkpoints(checkpoint_callback) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/pytorch_lightning/loggers/wandb.py", line 594, in _scan_and_log_checkpoints artifact = wandb.Artifact(name=f"model-{self.experiment.id}", type="model", metadata=metadata) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/wandb/sdk/wandb_artifacts.py", line 164, in __init__ metadata = _normalize_metadata(metadata) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/site-packages/wandb/sdk/wandb_artifacts.py", line 98, in _normalize_metadata Dict[str, Any], json.loads(json.dumps(util.make_safe_for_json(metadata))) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/json/__init__.py", line 231, in dumps return _default_encoder.encode(obj) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/home/nkjx/miniconda3/envs/keypoint-detection/lib/python3.9/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.__class__.__name__} ' TypeError: Object of type Tensor is not JSON serializable

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.