Skip to content

Commit

Permalink
Add train.py run succesfully on all BOP datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-nguyen committed May 9, 2023
1 parent 4fe529c commit e20ad3f
Show file tree
Hide file tree
Showing 16 changed files with 466 additions and 45 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ conda env create -f environment.yml
conda activate template
```

### 2. Datasets (from scratch) :smiley_cat: :electric_plug:
### 2. Datasets
First, create template poses from icosahedron:
```
blenderproc run src/poses/create_poses.py
Expand All @@ -90,6 +90,24 @@ TODO
```
</details>

## Launch a training

<details><summary>Click to expand</summary>

### 1. Mixing all BOP datasets except LINEMOD and T-LESS (only objects 19-30)
```
python train.py name_exp=train_all
```

The parsing is done with Hydra library. You can override anything in the configuration by passing arguments. For example:
```
# experiment 1: change batch_size, using data augmentation, update name_exp
python train.py machine.batch_size=2 use_augmentation=True name_exp=train_augmentation
# experiment 2: change batch_size, using data augmentation, update name_exp, update_lr
python train.py machine.batch_size=2 use_augmentation=True model.lr=0.001 name_exp=train_augmentation_lr0.001
```
</details>

## Acknowledgement

Expand Down
8 changes: 8 additions & 0 deletions configs/data/hb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ source:
unzip_mode: unzip
processing:

dataloader:
_target_: src.dataloader.bop.BOPDataset
root_dir: ${machine.root_dir}/hb
template_dir: ${machine.root_dir}/templates/hb
obj_ids:
reset_metaData: True
img_size: 256
cropping_with_bbox: True
8 changes: 8 additions & 0 deletions configs/data/hope.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ source:
unzip_mode: unzip
processing:

dataloader:
_target_: src.dataloader.bop.BOPDataset
root_dir: ${machine.root_dir}/hope
template_dir: ${machine.root_dir}/templates/hope
obj_ids:
reset_metaData: True
img_size: 256
cropping_with_bbox: True
8 changes: 8 additions & 0 deletions configs/data/icbin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ source:
unzip_mode: unzip
processing:

dataloader:
_target_: src.dataloader.bop.BOPDataset
root_dir: ${machine.root_dir}/icbin
template_dir: ${machine.root_dir}/templates/icbin
obj_ids:
reset_metaData: True
img_size: 256
cropping_with_bbox: True
8 changes: 8 additions & 0 deletions configs/data/icmi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ source:
unzip_mode: unzip
processing:

dataloader:
_target_: src.dataloader.bop.BOPDataset
root_dir: ${machine.root_dir}/icmi
template_dir: ${machine.root_dir}/templates/icmi
obj_ids:
reset_metaData: True
img_size: 256
cropping_with_bbox: True
5 changes: 3 additions & 2 deletions configs/data/lm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ source:
processing:

dataloader:
_target_: src.dataloader.lm.LINEMOD
_target_: src.dataloader.bop.LINEMOD
root_dir: ${machine.root_dir}/lm
template_dir: ${machine.root_dir}/templates/linemod
split_name: ${split_name}
reset_metaData: True
mode:
img_size: 256
img_size: 256
cropping_with_bbox: True
8 changes: 8 additions & 0 deletions configs/data/ruapc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ source:
unzip_mode: unzip
processing:

dataloader:
_target_: src.dataloader.bop.BOPDataset
root_dir: ${machine.root_dir}/ruapc
template_dir: ${machine.root_dir}/templates/ruapc
obj_ids:
reset_metaData: True
img_size: 256
cropping_with_bbox: True
8 changes: 8 additions & 0 deletions configs/data/tless_train.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ source:
unzip_mode: unzip
processing:

dataloader:
_target_: src.dataloader.bop.BOPDataset
root_dir: ${machine.root_dir}/tless/train
template_dir: ${machine.root_dir}/templates/tless
obj_ids:
reset_metaData: True
img_size: 256
cropping_with_bbox: True
11 changes: 10 additions & 1 deletion configs/data/tudl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ source:
cad_url: https://bop.felk.cvut.cz/media/data/bop_datasets/tudl_models.zip
http: True
unzip_mode: unzip
processing:
processing:

dataloader:
_target_: src.dataloader.bop.BOPDataset
root_dir: ${machine.root_dir}/tudl
template_dir: ${machine.root_dir}/templates/tudl
obj_ids:
reset_metaData: True
img_size: 256
cropping_with_bbox: True
2 changes: 1 addition & 1 deletion configs/model/resnet50.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
modelname: FeatureExtractor
_target_: src.model.network.FeatureExtractor

descriptor_size: 16
descriptor_size: 8
threshold: 0.2
pretrained_weight: ${machine.root_dir}/pretrained/moco_v2_800ep_pretrain.pth

Expand Down
1 change: 1 addition & 0 deletions configs/train.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ defaults:
save_dir: ${machine.root_dir}/results/${name_exp}
name_exp: train
use_pretrained: True
use_augmentation: False
train_datasets:
- tless_train
- hb
Expand Down
20 changes: 17 additions & 3 deletions src/dataloader/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ def load_list_scene(self, split=None):
if isinstance(split, str):
if split is not None:
split_folder = osp.join(self.root_dir, split)
else:
split_folder = self.root_dir
self.list_scenes = sorted(
[
osp.join(split_folder, scene)
Expand All @@ -65,6 +63,8 @@ def load_list_scene(self, split=None):
if os.path.isdir(osp.join(self.root_dir, scene))
]
)
else:
raise NotImplementedError
logging.info(f"Found {len(self.list_scenes)} scenes")

def load_scene(self, path, use_visible_mask=True):
Expand Down Expand Up @@ -100,6 +100,8 @@ def load_metaData(self, reset_metaData, mode="query", split="test", level=2):
"mask_visib_path": [],
"depth_path": [],
"visib_fract": [],
"bbox_obj": [],
"bbox_visib": [],
"intrinsic": [],
"idx_template": [],
"inplane": [],
Expand Down Expand Up @@ -182,7 +184,19 @@ def load_metaData(self, reset_metaData, mode="query", split="test", level=2):
video_metaData["scene_camera"][f"{id_frame}"]["cam_K"]
)
metaData["visib_fract"].append(
video_metaData["scene_gt_info"][f"{id_frame}"][idx_obj]
video_metaData["scene_gt_info"][f"{id_frame}"][idx_obj][
"visib_fract"
]
)
metaData["bbox_obj"].append(
video_metaData["scene_gt_info"][f"{id_frame}"][idx_obj][
"bbox_obj"
]
)
metaData["bbox_visib"].append(
video_metaData["scene_gt_info"][f"{id_frame}"][idx_obj][
"bbox_visib"
]
)
metaData["idx_template"].append(
templates_frame[idx_obj]["idx_template"]
Expand Down
Loading

0 comments on commit e20ad3f

Please sign in to comment.