To use the SC6D-pose repository with a custom dataset, you need to adapt the dataset format and training pipeline to match the framework's requirements. Here's a detailed guide based on the provided repository files:
1. Understand the Dataset Requirements
The SC6D framework is designed to work with datasets following the BOP (Benchmark for 6D Object Pose Estimation) format. The repository already supports three datasets: tless, itodd, and ycbv. Custom datasets should similarly provide:
RGB images
Mask annotations (e.g., object masks)
Intrinsic camera parameters
Ground-truth 6D object poses (rotation matrices and 3D translations)
Bounding box information
For more details, refer to the BOP_Dataset class in ./repos/SC6D-pose/dataset/bop_dataset.py.
2. Prepare Your Custom Dataset
You need to structure your dataset in the BOP format. Here's what each component of the dataset should include:
Images: RGB images of the objects, saved as .png or .jpg files.
Masks: Binary segmentation masks for each object instance in the images.
Intrinsic Camera Parameters: A JSON file providing the camera intrinsics (e.g., cam_K).
6D Object Poses: Ground-truth rotation matrices (cam_R_m2c) and translations (cam_t_m2c) for each object.
Add a new entry for your dataset in the DATASET_CONFIG dictionary in ./repos/SC6D-pose/config.py. For example:
python
DATASET_CONFIG = {
'my_custom_dataset': {
'width': 640,
'height': 480,
'Tz_near': 0.010,
'Tz_far': 2.000,
'num_class': 10, # Number of object classes
'id2mod': {v+1: "obj_{:02d}".format(v+1) for v in range(10)}, # Object model names
'id2cls': {v+1: v for v in range(10)}, # Object ID to class index
'train_set': ['train_pbr'], # Training subsets
'test_set': 'test', # Test subset
},
}
Key fields to update:
width and height: Dimensions of your dataset images.
Tz_near and Tz_far: Near and far bounds for depth estimation.
num_class: Number of object classes.
id2mod and id2cls: Mapping of object IDs to model names and class indices.
train_set and test_set: Specify the training and testing subsets.
4. Place Your Dataset
Ensure the dataset is placed in the directory specified by DATASET_ROOT in config.py:
The BOP_Dataset class in ./repos/SC6D-pose/dataset/bop_dataset.py handles dataset loading. If your dataset deviates slightly from the BOP format, update this class accordingly:
Update paths to your dataset's files (e.g., scene_camera.json, scene_gt.json).
Ensure self.dataset_id2cls and other mappings match your dataset.
Update how masks, bounding boxes, and poses are read if necessary.
6. Training with the Custom Dataset
Use the provided training.sh script to train on the custom dataset. Update the NAME variable with your dataset name:
Test the dataset loading by creating a DataLoader instance:
python
from dataset.bop_dataset import BOP_Dataset
import config as bop_cfg
dataset_name = 'my_custom_dataset'
dataset = BOP_Dataset(dataset_name, bop_cfg)
print(len(dataset)) # Number of samples
sample = dataset[0] # Test loading the first sample
Check for errors in dataset formatting, bounding boxes, or pose data.
9. Optional: Pre-trained Models
If you have similar objects to those in tless, itodd, or ycbv, you can fine-tune their pre-trained models. Download the models here and place them in the checkpoints directory.
Summary
Convert your dataset to the BOP format.
Update config.py for your custom dataset.
Modify the BOP_Dataset class if necessary.
Train the model using training.sh.
Evaluate and refine the dataset and training pipeline.
This process enables SC6D to work seamlessly with your custom dataset!