未验证 提交 74a3bd04 编写于 作者: K Kaipeng Deng 提交者: GitHub

refine yolov3/rcnn/ssd dataset download (#3638)

* refine yolov3/rcnn/ssd dataset download

* refine docs
上级 431fb9d6
......@@ -38,8 +38,9 @@ Mask RCNN is a two stage model as well. At the first stage, it generates proposa
Train the model on [MS-COCO dataset](http://cocodataset.org/#download), download dataset as below:
cd dataset/coco
./download.sh
```bash
python dataset/coco/download.py
```
The data catalog structure is as follows:
......@@ -67,6 +68,8 @@ The data catalog structure is as follows:
sh ./pretrained/download.sh
**NOTE:** Windows users can download weights from links in `./pretrained/download.sh`.
Set `pretrained_model` to load pre-trained model. In addition, this parameter is used to load trained model when finetuning as well.
Please make sure that pretrained_model is downloaded and loaded correctly, otherwise, the loss may be NAN during training.
......
......@@ -38,8 +38,9 @@ Mask RCNN同样为两阶段框架,第一阶段扫描图像生成候选框;
[MS-COCO数据集](http://cocodataset.org/#download)上进行训练,通过如下方式下载数据集。
cd dataset/coco
./download.sh
```bash
python dataset/coco/download.py
```
数据目录结构如下:
......@@ -68,6 +69,8 @@ data/coco/
sh ./pretrained/download.sh
**注意:** Windows用户可通过`./pretrained/download.sh`中的链接直接下载和解压。
通过初始化`pretrained_model` 加载预训练模型。同时在参数微调时也采用该设置加载已训练模型。
请在训练前确认预训练模型下载与加载正确,否则训练过程中损失可能会出现NAN。
......
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import os.path as osp
import sys
import zipfile
import logging
from paddle.dataset.common import download
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
DATASETS = {
'coco': [
# coco2017
('http://images.cocodataset.org/zips/train2017.zip',
'cced6f7f71b7629ddf16f17bbcfab6b2', ),
('http://images.cocodataset.org/zips/val2017.zip',
'442b8da7639aecaf257c1dceb8ba8c80', ),
('http://images.cocodataset.org/annotations/annotations_trainval2017.zip',
'f4bbac642086de4f52a3fdda2de5fa2c', ),
# coco2014
('http://images.cocodataset.org/zips/train2014.zip',
'0da8c0bd3d6becc4dcb32757491aca88', ),
('http://images.cocodataset.org/zips/val2014.zip',
'a3d79f5ed8d289b7a7554ce06a5782b3', ),
('http://images.cocodataset.org/annotations/annotations_trainval2014.zip',
'0a379cfc70b0e71301e0f377548639bd', ),
],
}
def download_decompress_file(data_dir, url, md5):
logger.info("Downloading from {}".format(url))
zip_file = download(url, data_dir, md5)
logger.info("Decompressing {}".format(zip_file))
with zipfile.ZipFile(zip_file) as zf:
zf.extractall(path=data_dir)
os.remove(zip_file)
if __name__ == "__main__":
data_dir = osp.split(osp.realpath(sys.argv[0]))[0]
for name, infos in DATASETS.items():
for info in infos:
download_decompress_file(data_dir, info[0], info[1])
logger.info("Download dataset {} finished.".format(name))
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
cd "$DIR"
# Download the data.
echo "Downloading..."
wget http://images.cocodataset.org/zips/train2014.zip
wget http://images.cocodataset.org/zips/val2014.zip
wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip
wget http://images.cocodataset.org/annotations/annotations_trainval2014.zip
wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip
# Extract the data.
echo "Extracting..."
unzip train2014.zip
unzip val2014.zip
unzip train2017.zip
unzip val2017.zip
unzip annotations_trainval2014.zip
unzip annotations_trainval2017.zip
......@@ -26,10 +26,10 @@ Please download [PASCAL VOC dataset](http://host.robots.ox.ac.uk/pascal/VOC/) at
```
cd data/pascalvoc
./download.sh
python download.py
```
The command `download.sh` also will create training and testing file lists.
The script `download.py` will also create training and testing file lists.
### Train
......@@ -37,9 +37,11 @@ The command `download.sh` also will create training and testing file lists.
We provide two pre-trained models. The one is MobileNet-v1 SSD trained on COCO dataset, but removed the convolutional predictors for COCO dataset. This model can be used to initialize the models when training other datasets, like PASCAL VOC. The other pre-trained model is MobileNet-v1 trained on ImageNet 2012 dataset but removed the last weights and bias in the Fully-Connected layer. Download MobileNet-v1 SSD:
```
./pretrained/download_coco.sh
```
```bash
sh ./pretrained/download_coco.sh
```
**NOTE:** Windows users can download weights from link in `./pretrained/download_coco.sh`.
Declaration: the MobileNet-v1 SSD model is converted by [TensorFlow model](https://github.com/tensorflow/models/blob/f87a58cd96d45de73c9a8330a06b2ab56749a7fa/research/object_detection/g3doc/detection_model_zoo.md).
......
......@@ -27,10 +27,10 @@ SSD 可以方便地插入到任何一种标准卷积网络中,比如 VGG、Res
```
cd data/pascalvoc
./download.sh
python download.py
```
`download.sh` 命令会自动创建训练和测试用的列表文件。
`download.py` 脚本会自动创建训练和测试用的列表文件。
### 模型训练
......@@ -39,9 +39,11 @@ cd data/pascalvoc
我们提供了两个预训练模型。第一个模型是在 COCO 数据集上预训练的 MobileNet-v1 SSD,我们将它的预测头移除了以便在 COCO 以外的数据集上进行训练。第二个模型是在 ImageNet 2012 数据集上预训练的 MobileNet-v1,我们也将最后的全连接层移除以便进行目标检测训练。下载 MobileNet-v1 SSD:
```
./pretrained/download_coco.sh
```
```bash
sh ./pretrained/download_coco.sh
```
**注意:** Windows用户可通过`./pretrained/download_coco.sh`中的链接直接下载和解压。
声明:MobileNet-v1 SSD 模型转换自[TensorFlow model](https://github.com/tensorflow/models/blob/f87a58cd96d45de73c9a8330a06b2ab56749a7fa/research/object_detection/g3doc/detection_model_zoo.md)。MobileNet-v1 模型转换自[Caffe](https://github.com/shicai/MobileNet-Caffe)
......
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import os.path as osp
import sys
import zipfile
import logging
from paddle.dataset.common import download
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
DATASETS = {
'coco': [
# coco2017
('http://images.cocodataset.org/zips/train2017.zip',
'cced6f7f71b7629ddf16f17bbcfab6b2', ),
('http://images.cocodataset.org/zips/val2017.zip',
'442b8da7639aecaf257c1dceb8ba8c80', ),
('http://images.cocodataset.org/annotations/annotations_trainval2017.zip',
'f4bbac642086de4f52a3fdda2de5fa2c', ),
# coco2014
('http://images.cocodataset.org/zips/train2014.zip',
'0da8c0bd3d6becc4dcb32757491aca88', ),
('http://images.cocodataset.org/zips/val2014.zip',
'a3d79f5ed8d289b7a7554ce06a5782b3', ),
('http://images.cocodataset.org/annotations/annotations_trainval2014.zip',
'0a379cfc70b0e71301e0f377548639bd', ),
],
}
def download_decompress_file(data_dir, url, md5):
logger.info("Downloading from {}".format(url))
zip_file = download(url, data_dir, md5)
logger.info("Decompressing {}".format(zip_file))
with zipfile.ZipFile(zip_file) as zf:
zf.extractall(path=data_dir)
os.remove(zip_file)
if __name__ == "__main__":
data_dir = osp.split(osp.realpath(sys.argv[0]))[0]
for name, infos in DATASETS.items():
for info in infos:
download_decompress_file(data_dir, info[0], info[1])
logger.info("Download dataset {} finished.".format(name))
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
cd "$DIR"
# Download the data.
echo "Downloading..."
wget http://images.cocodataset.org/zips/train2014.zip
wget http://images.cocodataset.org/zips/val2014.zip
wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip
wget http://images.cocodataset.org/annotations/annotations_trainval2014.zip
wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip
# Extract the data.
echo "Extracting..."
unzip train2014.zip
unzip val2014.zip
unzip train2017.zip
unzip val2017.zip
unzip annotations_trainval2014.zip
unzip annotations_trainval2017.zip
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
......@@ -11,10 +11,31 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import os.path as osp
import sys
import re
import random
import tarfile
import logging
from paddle.dataset.common import download
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
DATASETS = {
'pascalvoc': [
('http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar',
'6cd6e144f989b92b3379bac3b3de84fd', ),
('http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar',
'c52e279531787c972589f7e41ab4ae64', ),
('http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar',
'b6e924de25625d8de591ea690078ad9f', ),
],
}
devkit_dir = './VOCdevkit'
years = ['2007', '2012']
......@@ -73,5 +94,22 @@ def prepare_filelist(devkit_dir, years, output_dir):
ftest.write(item[0] + ' ' + item[1] + '\n')
if __name__ == '__main__':
prepare_filelist(devkit_dir, years, '.')
def download_decompress_file(data_dir, url, md5):
logger.info("Downloading from {}".format(url))
tar_file = download(url, data_dir, md5)
logger.info("Decompressing {}".format(tar_file))
with tarfile.open(tar_file) as tf:
tf.extractall(path=data_dir)
os.remove(tar_file)
if __name__ == "__main__":
data_dir = osp.split(osp.realpath(sys.argv[0]))[0]
for name, infos in DATASETS.items():
for info in infos:
download_decompress_file(data_dir, info[0], info[1])
if name == 'pascalvoc':
logger.info("create list for pascalvoc dataset.")
prepare_filelist(devkit_dir, years, data_dir)
logger.info("Download dataset {} finished.".format(name))
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
cd "$DIR"
# Download the data.
echo "Downloading..."
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtrainval_06-Nov-2007.tar
wget http://host.robots.ox.ac.uk/pascal/VOC/voc2007/VOCtest_06-Nov-2007.tar
# Extract the data.
echo "Extracting..."
tar -xf VOCtrainval_11-May-2012.tar
tar -xf VOCtrainval_06-Nov-2007.tar
tar -xf VOCtest_06-Nov-2007.tar
echo "Creating data lists..."
python create_list.py
......@@ -7,5 +7,6 @@ checkpoints/
weights/
!weights/*.sh
dataset/coco/
!dataset/coco/*.py
log*
output*
......@@ -50,8 +50,9 @@
[MS-COCO数据集](http://cocodataset.org/#download)上进行训练,通过如下方式下载数据集。
cd dataset/coco
./download.sh
```bash
python dataset/coco/download.py
```
数据目录结构如下:
......@@ -84,6 +85,8 @@ dataset/coco/
sh ./weights/download.sh
**注意:** Windows用户可通过`./weights/download.sh`中的链接直接下载和解压。
通过设置`--pretrain` 加载预训练模型。同时在fine-tune时也采用该设置加载已训练模型。
请在训练前确认预训练模型下载与加载正确,否则训练过程中损失可能会出现NAN。
......
......@@ -50,8 +50,9 @@ To train the model, COCO-API is needed. Installation is as follows:
Train the model on [MS-COCO dataset](http://cocodataset.org/#download), we also provide download script as follows:
cd dataset/coco
./download.sh
```bash
python dataset/coco/download.py
```
The data catalog structure is as follows:
......@@ -84,6 +85,8 @@ You can defined datasets by yourself, we recommend using annotations in COCO for
sh ./weights/download.sh
**NOTE:** Windows users can download weights from links in `./weights/download.sh`.
Set `--pretrain` to load pre-trained model. In addition, this parameter is used to load trained model when finetuning as well.
Please make sure that pre-trained model is downloaded and loaded correctly, otherwise, the loss may be NAN during training.
......
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import os.path as osp
import sys
import zipfile
import logging
from paddle.dataset.common import download
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
DATASETS = {
'coco': [
# coco2017
('http://images.cocodataset.org/zips/train2017.zip',
'cced6f7f71b7629ddf16f17bbcfab6b2', ),
('http://images.cocodataset.org/zips/val2017.zip',
'442b8da7639aecaf257c1dceb8ba8c80', ),
('http://images.cocodataset.org/annotations/annotations_trainval2017.zip',
'f4bbac642086de4f52a3fdda2de5fa2c', ),
# coco2014
('http://images.cocodataset.org/zips/train2014.zip',
'0da8c0bd3d6becc4dcb32757491aca88', ),
('http://images.cocodataset.org/zips/val2014.zip',
'a3d79f5ed8d289b7a7554ce06a5782b3', ),
('http://images.cocodataset.org/annotations/annotations_trainval2014.zip',
'0a379cfc70b0e71301e0f377548639bd', ),
],
}
def download_decompress_file(data_dir, url, md5):
logger.info("Downloading from {}".format(url))
zip_file = download(url, data_dir, md5)
logger.info("Decompressing {}".format(zip_file))
with zipfile.ZipFile(zip_file) as zf:
zf.extractall(path=data_dir)
os.remove(zip_file)
if __name__ == "__main__":
data_dir = osp.split(osp.realpath(sys.argv[0]))[0]
for name, infos in DATASETS.items():
for info in infos:
download_decompress_file(data_dir, info[0], info[1])
logger.info("Download dataset {} finished.".format(name))
DIR="$( cd "$(dirname "$0")" ; pwd -P )"
cd "$DIR"
# Download the data.
echo "Downloading..."
wget http://images.cocodataset.org/zips/train2014.zip
wget http://images.cocodataset.org/zips/val2014.zip
wget http://images.cocodataset.org/zips/train2017.zip
wget http://images.cocodataset.org/zips/val2017.zip
wget http://images.cocodataset.org/annotations/annotations_trainval2014.zip
wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip
# Extract the data.
echo "Extracting..."
unzip train2014.zip
unzip val2014.zip
unzip train2017.zip
unzip val2017.zip
unzip annotations_trainval2014.zip
unzip annotations_trainval2017.zip
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册