Spaces:
Runtime error
Runtime error
A newer version of the Gradio SDK is available:
6.1.0
Convert your own dataset for DeepLab2 framework
You may want to train DeepLab2 on your own dataset. Here, we provide some guidances and hopefully that will facillitate the preparation process.
- Prepare your own dataset.
- Images should be stored either in
jpgorpngformat. - Annotations should be stored either in
pngorrawformat. The DeepLab2 framework assumes the panoptic label format (i.e.,panoptic_label = semantic_label * label_divisor + instance_id, where thelabel_divisorshould be larger than the maximum number of instances per image). Therawformat refers to the case where we could save the panoptic annotations in the int32 array (e.g., int32_numpy_array.tostring()).
- Convert the dataset to TFRecord.
- Update our provided example code (e.g., build_step_data.py)to convert your dataset to TFRecord.
- Modify the
dataset.py(path:${DEEPLAB2}/data/dataset.py) to provide your dataset information.
- Set the
panoptic_label_divisor(i.e., thelabel_divisorabove) correctly. Its value should be larger than the maximum number of instances that could appear per image in your dataset. - Set the
ignore_labelproperly. Pixels annotated withignore_labelare not used during both training and evaluation. If your dataset does not contain theignore_labelannotations, you could simply set it to be a large value (e.g., 255 as for Cityscapes). - Set the
class_has_instance_listproperly. The variable specifies which class belongs to thethingclass (i.e., countable objects such as people, cars). - Set the colormap (for visualization) properly. You may also need to
define your own colormap (see
${DEEPLAB2}/trainer/vis_utils.py).
- Prepare the experiment config.
- Update our provided example configs (path:
${DEEPLAB2}/configs/${DATASET}/${MODEL}/${BACKBONE}) for your use case. A few things that may worth your attention:- Set the
crop_sizecorrectly for both training and evaluation. See Q2 in FAQ for more details. - Tune the config flags for your dataset (e.g.,
base_learning_rate,training_number_of_step, and so on).
- Set the
Finally, if your dataset only contains semantic segmentation annotations, you could still use DeepLab2 framework with some minor changes:
- Set
panoptic_label_divisor=Nonein dataset.py (we also provide one example in dataset.py, where we only train with semantic segmentation on Cityscapes). - Have a config similar to
${DEEPLAB2}/configs/cityscapes/panoptic_deeplab/ resnet50_os32_semseg.textproto, where the instance branch is not initiated.
At this point, you are good to go! Enjoy training DeepLab2!