Skip to content

Commit c4039ea

Browse files
sdg and training workflow
0 parents  commit c4039ea

File tree

132 files changed

+3192
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+3192
-0
lines changed

CLA.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## Individual Contributor License Agreement (CLA)
2+
3+
**Thank you for submitting your contributions to this project.**
4+
5+
By signing this CLA, you agree that the following terms apply to all of your past, present and future contributions
6+
to the project.
7+
8+
### License.
9+
10+
You hereby represent that all present, past and future contributions are governed by the
11+
[MIT License](https://opensource.org/licenses/MIT)
12+
copyright statement.
13+
14+
This entails that to the extent possible under law, you transfer all copyright and related or neighboring rights
15+
of the code or documents you contribute to the project itself or its maintainers.
16+
Furthermore you also represent that you have the authority to perform the above waiver
17+
with respect to the entirety of you contributions.
18+
19+
### Moral Rights.
20+
21+
To the fullest extent permitted under applicable law, you hereby waive, and agree not to
22+
assert, all of your “moral rights” in or relating to your contributions for the benefit of the project.
23+
24+
### Third Party Content.
25+
26+
If your Contribution includes or is based on any source code, object code, bug fixes, configuration changes, tools,
27+
specifications, documentation, data, materials, feedback, information or other works of authorship that were not
28+
authored by you (“Third Party Content”) or if you are aware of any third party intellectual property or proprietary
29+
rights associated with your Contribution (“Third Party Rights”),
30+
then you agree to include with the submission of your Contribution full details respecting such Third Party
31+
Content and Third Party Rights, including, without limitation, identification of which aspects of your
32+
Contribution contain Third Party Content or are associated with Third Party Rights, the owner/author of the
33+
Third Party Content and Third Party Rights, where you obtained the Third Party Content, and any applicable
34+
third party license terms or restrictions respecting the Third Party Content and Third Party Rights. For greater
35+
certainty, the foregoing obligations respecting the identification of Third Party Content and Third Party Rights
36+
do not apply to any portion of a Project that is incorporated into your Contribution to that same Project.
37+
38+
### Representations.
39+
40+
You represent that, other than the Third Party Content and Third Party Rights identified by
41+
you in accordance with this Agreement, you are the sole author of your Contributions and are legally entitled
42+
to grant the foregoing licenses and waivers in respect of your Contributions. If your Contributions were
43+
created in the course of your employment with your past or present employer(s), you represent that such
44+
employer(s) has authorized you to make your Contributions on behalf of such employer(s) or such employer
45+
(s) has waived all of their right, title or interest in or to your Contributions.
46+
47+
### Disclaimer.
48+
49+
To the fullest extent permitted under applicable law, your Contributions are provided on an "as is"
50+
basis, without any warranties or conditions, express or implied, including, without limitation, any implied
51+
warranties or conditions of non-infringement, merchantability or fitness for a particular purpose. You are not
52+
required to provide support for your Contributions, except to the extent you desire to provide support.
53+
54+
### No Obligation.
55+
56+
You acknowledge that the maintainers of this project are under no obligation to use or incorporate your contributions
57+
into the project. The decision to use or incorporate your contributions into the project will be made at the
58+
sole discretion of the maintainers or their authorized delegates.

LICENSE.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
SPDX-License-Identifier: MIT
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a
5+
copy of this software and associated documentation files (the "Software"),
6+
to deal in the Software without restriction, including without limitation
7+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
and/or sell copies of the Software, and to permit persons to whom the
9+
Software is furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Synthetic Data Generation and Training with Sim Ready Assets
2+
This project provides a workflow for Training Computer Vision models with Synthetic Data. We will use Isaac Sim with Omniverse Replicator to generate data for our use case and objects of interest. To ensure seamless compatibility with model training, the data generated is in the KITTI format.
3+
4+
These steps can be followed on a Cloud/remote GPU instance or locally
5+
6+
## How to use this repository
7+
- [Guide](local/README.md) for running the workflow locally
8+
- [Guide](cloud/README.md) for running on a cloud/remote instance
9+
10+
## Workflow Components:
11+
* Generating Data: Use Isaac Sim to generate data
12+
* Training: We will use TAO toolkit, however users can train a model in a framework of their choice with data generated
13+
14+
### SDG
15+
- Using the `palletjack` assets from the Warehouse Sim Ready Asset collection
16+
17+
- Carry out Domain Randomization in the scene with Replicator:
18+
- Various attributes of the scene like lighting, textures, object pose and materials can be modified
19+
- Important to generate a good quality dataset to ensure model detects objects in the real world
20+
21+
- Data output KITTI format
22+
- We will use the KITTI Writer for generating annotations
23+
- Possible to implement a custom writer (can be useful when data is expected in a certain format for your model)
24+
25+
- Sample generated images:
26+
27+
<p>
28+
<img src="images/sample_synthetic/21.png" height="256"/>
29+
<img src="images/sample_synthetic/653.png" height="256"/>
30+
</p>
31+
32+
<p>
33+
<img src="images/sample_synthetic/896.png" height="256"/>
34+
<img src="images/sample_synthetic/1545.png" height="256"/>
35+
</p>
36+
37+
38+
39+
### Training
40+
- TAO: Outline of steps
41+
- Generating Tfrecords
42+
43+
- Model training and evaluation
44+
- Model backbone selction
45+
- Hyperparameters specified via `spec` file (provided with repo)
46+
- Running inference with trained model
47+
48+
- Sample real world detections on LOCO dataset images:
49+
50+
<p>
51+
<img src="images/real_world_results/1564562568.298206.jpg" height="256"/>
52+
<img src="images/real_world_results/1564562843.0618184.jpg" height="256"/>
53+
</p>
54+
55+
<p>
56+
<img src="images/real_world_results/593768,3659.jpg" height="256"/>
57+
<img src="images/real_world_results/510196244,1362.jpg" height="256"/>
58+
</p>
59+
60+
<p>
61+
<img src="images/real_world_results/1574675156.7667925.jpg" height="256"/>
62+
<img src="images/real_world_results/426023,9672.jpg" height="256"/>
63+
</p>
64+
65+
66+
### Deployment
67+
- Perform Optimizations: Pruning and QAT with TAO to reduce model size and improve performance
68+
- Deploy on NVIDIA Jetson powered Robot with Isaac ROS or Deepstream
69+
70+
71+
## References:
72+
- Real world images from the [LOCO dataset](https://github.com/tum-fml/loco) are used for visualizing model performance

cloud/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Requirements
2+
- Access to a cloud/remote GPU instance (workflow tested on a `g4dn` AWS EC2 instance with T4 GPU)
3+
- Docker setup instructions are provided in the notebooks
4+
- Entire workflow can be run in `headless` mode (SDG script and training)
5+
6+
7+
## Synthetic Data Generation
8+
- Use the Isaac Sim docker container for running the Data Generation [script](../palletjack_sdg/palletjack_datagen.sh)
9+
- We will generate data for warehouse `palletjack` objects in KITTI format
10+
- Follow the steps in the `cloud_sdg` notebook
11+
- This generated data can be used to train your own model (framework and architecture of your choice), in this workflow we demonstrate using TAO for training
12+
13+
14+
## Training with TAO Toolkit
15+
- The `training/cloud_train` notebook provides a walkthrough of the steps:
16+
- Setting up TAO docker container
17+
- Downloading pre-trained model, we will use the `DetectNet_v2` model with a `resnet_18` backbone
18+
- Running TAO training with `spec` files provided
19+
- Visualizing model performance on real world data
20+
- Visualize model metric with Tensorboard
21+
<img src="../images/tensorboard/tensorboard_resized_palletjack.png"/>
22+
23+
24+
## Next steps
25+
26+
### Generating Synthetic Data for your use case
27+
- Make changes in the Domain Randomization under the Synthetic Data Generation [script](../palletjack_sdg/standalone_palletjack_sdg.py)
28+
- Add additional objects of interest in the scene (similar to how palletjacks are added, you can add forklifts, ladders etc.) to generate dataUse different models for training with TAO (for object detection, you can use YOLO, SSD, EfficientDet)
29+
- Replicator provides Semantic Segmentation, Instance Segmentation, Depth and various other ground truth annotations along with RGB. You can also write your own ground truth annotator (eg: Pose Estimation: Refer to [sample](https://docs.omniverse.nvidia.com/isaacsim/latest/tutorial_replicator_offline_pose_estimation.html) These can be used for training a model of your own framework and choice)
30+
- Exploring the option of using Synthetic + Real data for training a network. Can be particularly useful for generating more data around particular corner cases
31+
32+
### Deploying Trained Models
33+
- The trained model can be pruned and optimized for inference with TAO
34+
- This can then be deployed on a robot with NVIDIA Jetson

cloud/cloud_sdg.ipynb

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Part 1: Synthetic Data Generation and Training Workflow with Warehouse Sim Ready Assets\n",
8+
"\n",
9+
"This notebook is the first part of the SDG and Training Workflow. We will be focusing on generating Synthetic Data for our use case\n",
10+
"\n",
11+
"A high level overview of the steps:\n",
12+
"* Pulling Isaac Sim Docker Container \n",
13+
"* Using Replicator API for Data Generation with Domain Randomization\n"
14+
]
15+
},
16+
{
17+
"cell_type": "markdown",
18+
"metadata": {},
19+
"source": [
20+
"### Table of Contents\n",
21+
"\n",
22+
"This notebook shows provides an overview of generating synthetic data using Warehouse Sim Ready assets with Isaac Sim and Omniverse Replicator. We will generate data for the `palletjack` class of objects. \n",
23+
"\n",
24+
"1. [Set up Isaac Sim via Docker Container](#head-1)\n",
25+
"2. [Generate Data for Detecting Palletjacks](#head-2)\n",
26+
"3. [Deeper dive into SDG script](#head-3)\n"
27+
]
28+
},
29+
{
30+
"cell_type": "markdown",
31+
"metadata": {},
32+
"source": [
33+
"## 1. Set up Isaac Sim: Docker Container Installation <a class=\"anchor\" id=\"head-1\"></a>\n",
34+
"\n",
35+
"### This step can be skipped if the Isaac Sim Docker container has already been set up on your Cloud/Remote Instance\n",
36+
"\n",
37+
"* Follow the [instructions](https://docs.omniverse.nvidia.com/isaacsim/2022.2.1/install_container.html) for Isaac Sim Container Installation\n",
38+
"* Ensure that `docker run` command on Step 7 works as expected and you are able to enter the container. \n",
39+
"\n",
40+
"We will use `./python.sh` in the container to run our SDG script. Please make sure you exit the container before running the next cells "
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"metadata": {
46+
"tags": []
47+
},
48+
"source": [
49+
"## 2. Generate Data for Detecting Palletjacks <a class=\"anchor\" id=\"head-2\"></a>\n",
50+
"\n",
51+
"* We can find the Palletjack USDs in the Warehouse Sim Ready asset collection (`http://omniverse-content-production.s3-us-west-2.amazonaws.com/Assets/DigitalTwin/Assets/Warehouse/Equipment/Pallet_Trucks`)\n",
52+
"* First, we will mount our current local directory while running the docker container. This will ensure that we can run our scripts inside the Isaac Sim container. Data generated in the container will also be saved in this mounted directory."
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": 1,
58+
"metadata": {
59+
"tags": []
60+
},
61+
"outputs": [
62+
{
63+
"name": "stdout",
64+
"output_type": "stream",
65+
"text": [
66+
"/home/karma/Downloads/getting_started_v4.0.1/notebooks/tao_launcher_starter_kit/detectnet_v2/sdg_and_training/sdg-and-training/palletjack_sdg\n"
67+
]
68+
}
69+
],
70+
"source": [
71+
"import os\n",
72+
"\n",
73+
"# This is the directory which will be mounted into the Isaac Sim container. Make sure <path_to_repo_cloned> is updated correctly\n",
74+
"# os.environ[\"MOUNT_DIR\"]=os.path.join(<path_where_repo_cloned>, \"palletjack_sdg\")\n",
75+
"os.environ[\"LOCAL_PROJECT_DIR\"]=os.path.dirname(os.getcwd())\n",
76+
"os.environ[\"MOUNT_DIR\"] = os.path.join(os.getenv(\"LOCAL_PROJECT_DIR\"), \"palletjack_sdg\")\n",
77+
"print(os.getenv(\"MOUNT_DIR\"))"
78+
]
79+
},
80+
{
81+
"cell_type": "code",
82+
"execution_count": null,
83+
"metadata": {
84+
"scrolled": true,
85+
"tags": []
86+
},
87+
"outputs": [],
88+
"source": [
89+
"# Make sure the MOUNT_DIR location is correct, it shold have the scripts needed for SDG there\n",
90+
"\n",
91+
"!docker run --name isaac-sim --entrypoint bash -it --gpus all -e \"ACCEPT_EULA=Y\" --rm --network=host \\\n",
92+
" -v ~/docker/isaac-sim/cache/kit:/isaac-sim/kit/cache/Kit:rw \\\n",
93+
" -v ~/docker/isaac-sim/cache/ov:/root/.cache/ov:rw \\\n",
94+
" -v ~/docker/isaac-sim/cache/pip:/root/.cache/pip:rw \\\n",
95+
" -v ~/docker/isaac-sim/cache/glcache:/root/.cache/nvidia/GLCache:rw \\\n",
96+
" -v ~/docker/isaac-sim/cache/computecache:/root/.nv/ComputeCache:rw \\\n",
97+
" -v ~/docker/isaac-sim/logs:/root/.nvidia-omniverse/logs:rw \\\n",
98+
" -v ~/docker/isaac-sim/data:/root/.local/share/ov/data:rw \\\n",
99+
" -v ~/docker/isaac-sim/documents:/root/Documents:rw \\\n",
100+
" -v $MOUNT_DIR:/isaac-sim/palletjack_sdg \\\n",
101+
" nvcr.io/nvidia/isaac-sim:2022.2.1 \\\n",
102+
" ./palletjack_sdg/palletjack_datagen.sh\n",
103+
" \n",
104+
"# Make sure $MOUNT_DIR is set correctly from the cell above"
105+
]
106+
},
107+
{
108+
"cell_type": "markdown",
109+
"metadata": {},
110+
"source": [
111+
"\n",
112+
"The data generation will begin in `headless` mode. We will be generating 5k images and using a 90:10 split for training and validation. "
113+
]
114+
},
115+
{
116+
"cell_type": "code",
117+
"execution_count": null,
118+
"metadata": {
119+
"tags": []
120+
},
121+
"outputs": [],
122+
"source": [
123+
"# Once the data generation is complete, list the folders in the data directory\n",
124+
"\n",
125+
"!ls -rlt $MOUNT_DIR/palletjack_data\n",
126+
"\n",
127+
"# There hould be 3 folders -> 1. distractors_warehouse 2. distractors_additional 3. no_distractors "
128+
]
129+
},
130+
{
131+
"cell_type": "markdown",
132+
"metadata": {},
133+
"source": [
134+
"## 3. Deeper Dive into SDG Script <a class=\"anchor\" id=\"head-3\"></a>\n",
135+
"\n",
136+
"* The `standalone_palletjack_sdg.py` is the Python script which runs and generates data in headless mode inside the container.\n",
137+
"* The overall flow of the script is similar to the `standalone_examples/replicator/offline_generation.py` file provided as a starting point with Isaac Sim\n",
138+
"\n",
139+
"\n",
140+
"* We will be carrying out specific randomizations targeted to our use case. Some of them are:\n",
141+
" * Camera Pose Randomization -> Should be similar to a robot perspective in the scene\n",
142+
" * Palletjack Color Randomization -> To ensure model is robust to variations in Palletjack colors\n",
143+
" * Distractors Pose Randomization -> To enable the model to *focus* on the right object (Our object of interest: Palletjack)\n",
144+
" * Lighting Randomization-> Model robust to lights and reflections/shadows in the scene\n",
145+
" * Floor and Wall Texture Randomization -> Model more robust to changes in background textures and features <br> <br>\n",
146+
" \n",
147+
" \n",
148+
"* We are only interested in the `palletjack` object class, all other semantics are removed from the stage with the `update_semantics()` function\n",
149+
"\n",
150+
"* You can use a model of your own choice to train with this data (Pytorch/Tensorflow or other frameworks)\n",
151+
"\n",
152+
"* The data is written in the KITTI Format, this allows seamless integration with TAO to train a model. Refer to `training/cloud_train.ipynb` notebook (Part 2) for training with TAO\n"
153+
]
154+
}
155+
],
156+
"metadata": {
157+
"kernelspec": {
158+
"display_name": "Python 3 (ipykernel)",
159+
"language": "python",
160+
"name": "python3"
161+
},
162+
"language_info": {
163+
"codemirror_mode": {
164+
"name": "ipython",
165+
"version": 3
166+
},
167+
"file_extension": ".py",
168+
"mimetype": "text/x-python",
169+
"name": "python",
170+
"nbconvert_exporter": "python",
171+
"pygments_lexer": "ipython3",
172+
"version": "3.8.10"
173+
},
174+
"vscode": {
175+
"interpreter": {
176+
"hash": "f23a2831654361cfd8b219e05b5055fdda3e37fe5c0b020e6226f740844c300a"
177+
}
178+
}
179+
},
180+
"nbformat": 4,
181+
"nbformat_minor": 4
182+
}

0 commit comments

Comments
 (0)