https://github.com/facebookresearch/detectron2/blob/master/datasets/README.md
使用內置數據集
數據集可以通過進入detectron2.data package API(或者class name)的數據被使用,這個文檔解釋了如何設置內置的數據集,以便它們可以被上面的api使用,Use Custom Datasets(之后會翻譯Use Custom Datasets)
https://detectron2.readthedocs.io/tutorials/datasets.html 更好地教我們怎么用數據目錄和元數據目錄,怎么為他們添加新的數據集
Detectron2已經對一些數據集提供了支持,假定這些數據集存在於由環境變量(DETECTRON2_DATASETS)特定的目錄中,在這個目錄下,如果需要的話,detectron2將會在如下描述的結構中搜尋數據:
$DETECTRON2_DATASETS/ coco/ lvis/ cityscapes/ VOC20{07,12}/
你可以通過export DETECTRON2_DATASETS=/path/to/datasets
為內置的數據集設置位置,如果不設置的話,對你的當前的工作目錄來講,默認的為./datasets
,
model zoo包含了使用這些內置數據集的配置和模型
COCO instance/keypoint detection的理想型數據集結構:
coco/ annotations/ instances_{train,val}2017.json person_keypoints_{train,val}2017.json {train,val}2017/ # image files that are mentioned in the corresponding json
你同樣可以使用2014版本的數據集
一些內置的測試(dev/run_*_tests.sh)使用了你可以用(./prepare_for_tests.sh)下載的COCO數據集tiny版本
PanopticFPN(語義分割和實例分割的FCN和Mask R-CNN結合起來的全景分割研究)的理想型數據集結構:
coco/ annotations/ panoptic_{train,val}2017.json panoptic_{train,val}2017/ # png annotations panoptic_stuff_{train,val}2017/ # generated by the script mentioned below
通過以下指令安裝panopticapi:
pip install git+https://github.com/cocodataset/panopticapi.git
接着,運行 python prepare_panoptic_fpn.py 從展示全景的注釋(panoptic annotations)提取語義標注
大規模的詞匯實例分割數據集(LVIS instance segmentation)的理想型數據集結構:
coco/ {train,val,test}2017/ lvis/ lvis_v0.5_{train,val}.json lvis_v0.5_image_info_test.json lvis_v1_{train,val}.json lvis_v1_image_info_test{,_challenge}.json
安裝lvis-api:
pip install git+https://github.com/lvis-dataset/lvis-api.git
運行 python prepare_cocofied_lvis.py 評估使用 LVIS annotations 在COCO數據集上訓練的模型來准備“COCO化”的 LVIS annotations
(城市環境中駕駛場景)cityscapes 的理想型數據集結構:
cityscapes/ gtFine/ train/ aachen/ color.png, instanceIds.png, labelIds.png, polygons.json, labelTrainIds.png ... val/ test/ # below are generated Cityscapes panoptic annotation cityscapes_panoptic_train.json cityscapes_panoptic_train/ cityscapes_panoptic_val.json cityscapes_panoptic_val/ cityscapes_panoptic_test.json cityscapes_panoptic_test/ leftImg8bit/ train/ val/ test/
安裝cityscapes scripts :
pip install git+https://github.com/mcordts/cityscapesScripts.git
注意:為了創造 labelTrainIds.png, 首先准備以上的結構,接着運行cityscapesescript with:
CITYSCAPES_DATASET=/path/to/abovementioned/cityscapes python cityscapesscripts/preparation/createTrainIdLabelImgs.py
實力分割不需要這些文件
注意:為了獲得Cityscapes panoptic數據集,運行cityscapesescript with:
CITYSCAPES_DATASET=/path/to/abovementioned/cityscapes python cityscapesscripts/preparation/createPanopticImgs.py
語義(像素級別的分類)和實例分割(類的具體對象)不需要這些文件。(語義分割:人,實例分割:甲乙丙)
Pascal VOC期望的數據集結構:
VOC20{07,12}/ Annotations/ ImageSets/ Main/ trainval.txt test.txt # train.txt or val.txt, if you use these splits JPEGImages/
ADE20k Scene Parsing期望的數據集結構:
ADEChallengeData2016/ annotations/ annotations_detectron2/ images/ objectInfo150.txt
annotations_detectron2目錄是通過運行 python prepare_ade20k_sem_seg.py 生成的。