Arulkumar03/Wheat_HEAD_Detection_Counting_ComputerVision_Model
0
1# Use Builtin Datasets2 3A dataset can be used by accessing [DatasetCatalog](https://detectron2.readthedocs.io/modules/data.html#detectron2.data.DatasetCatalog)4for its data, or [MetadataCatalog](https://detectron2.readthedocs.io/modules/data.html#detectron2.data.MetadataCatalog) for its metadata (class names, etc).5This document explains how to setup the builtin datasets so they can be used by the above APIs.6[Use Custom Datasets](https://detectron2.readthedocs.io/tutorials/datasets.html) gives a deeper dive on how to use `DatasetCatalog` and `MetadataCatalog`,7and how to add new datasets to them.8 9Detectron2 has builtin support for a few datasets.10The datasets are assumed to exist in a directory specified by the environment variable11`DETECTRON2_DATASETS`.12Under this directory, detectron2 will look for datasets in the structure described below, if needed.13```14$DETECTRON2_DATASETS/15 coco/16 lvis/17 cityscapes/18 VOC20{07,12}/19```20 21You can set the location for builtin datasets by `export DETECTRON2_DATASETS=/path/to/datasets`.22If left unset, the default is `./datasets` relative to your current working directory.23 24The [model zoo](https://github.com/facebookresearch/detectron2/blob/master/MODEL_ZOO.md)25contains configs and models that use these builtin datasets.26 27## Expected dataset structure for [COCO instance/keypoint detection](https://cocodataset.org/#download):28 29```30coco/31 annotations/32 instances_{train,val}2017.json33 person_keypoints_{train,val}2017.json34 {train,val}2017/35 # image files that are mentioned in the corresponding json36```37 38You can use the 2014 version of the dataset as well.39 40Some of the builtin tests (`dev/run_*_tests.sh`) uses a tiny version of the COCO dataset,41which you can download with `./datasets/prepare_for_tests.sh`.42 43## Expected dataset structure for PanopticFPN:44 45Extract panoptic annotations from [COCO website](https://cocodataset.org/#download)46into the following structure:47```48coco/49 annotations/50 panoptic_{train,val}2017.json51 panoptic_{train,val}2017/ # png annotations52 panoptic_stuff_{train,val}2017/ # generated by the script mentioned below53```54 55Install panopticapi by:56```57pip install git+https://github.com/cocodataset/panopticapi.git58```59Then, run `python datasets/prepare_panoptic_fpn.py`, to extract semantic annotations from panoptic annotations.60 61## Expected dataset structure for [LVIS instance segmentation](https://www.lvisdataset.org/dataset):62```63coco/64 {train,val,test}2017/65lvis/66 lvis_v0.5_{train,val}.json67 lvis_v0.5_image_info_test.json68 lvis_v1_{train,val}.json69 lvis_v1_image_info_test{,_challenge}.json70```71 72Install lvis-api by:73```74pip install git+https://github.com/lvis-dataset/lvis-api.git75```76 77To evaluate models trained on the COCO dataset using LVIS annotations,78run `python datasets/prepare_cocofied_lvis.py` to prepare "cocofied" LVIS annotations.79 80## Expected dataset structure for [cityscapes](https://www.cityscapes-dataset.com/downloads/):81```82cityscapes/83 gtFine/84 train/85 aachen/86 color.png, instanceIds.png, labelIds.png, polygons.json,87 labelTrainIds.png88 ...89 val/90 test/91 # below are generated Cityscapes panoptic annotation92 cityscapes_panoptic_train.json93 cityscapes_panoptic_train/94 cityscapes_panoptic_val.json95 cityscapes_panoptic_val/96 cityscapes_panoptic_test.json97 cityscapes_panoptic_test/98 leftImg8bit/99 train/100 val/101 test/102```103Install cityscapes scripts by:104```105pip install git+https://github.com/mcordts/cityscapesScripts.git106```107 108Note: to create labelTrainIds.png, first prepare the above structure, then run cityscapesescript with:109```110CITYSCAPES_DATASET=/path/to/abovementioned/cityscapes python cityscapesscripts/preparation/createTrainIdLabelImgs.py111```112These files are not needed for instance segmentation.113 114Note: to generate Cityscapes panoptic dataset, run cityscapesescript with:115```116CITYSCAPES_DATASET=/path/to/abovementioned/cityscapes python cityscapesscripts/preparation/createPanopticImgs.py117```118These files are not needed for semantic and instance segmentation.119 120## Expected dataset structure for [Pascal VOC](http://host.robots.ox.ac.uk/pascal/VOC/index.html):121```122VOC20{07,12}/123 Annotations/124 ImageSets/125 Main/126 trainval.txt127 test.txt128 # train.txt or val.txt, if you use these splits129 JPEGImages/130```131 132## Expected dataset structure for [ADE20k Scene Parsing](http://sceneparsing.csail.mit.edu/):133```134ADEChallengeData2016/135 annotations/136 annotations_detectron2/137 images/138 objectInfo150.txt139```140The directory `annotations_detectron2` is generated by running `python datasets/prepare_ade20k_sem_seg.py`.141 