Skip to content
Snippets Groups Projects
Unverified Commit 25a9c4f2 authored by i-robot's avatar i-robot Committed by Gitee
Browse files

!3729 add create_train_lst.py for PSPNet

Merge pull request !3729 from hemaohua/master
parents bfeb203f ef49e901
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,12 @@ The pyramid pooling module fuses features under four different pyramid scales.Fo
- [PASCAL VOC 2012 and SBD Dataset Website](http://home.bharathh.info/pubs/codes/SBD/download.html)
- It contains 11,357 finely annotated images split into training and testing sets with 8,498 and 2,857 images respectively.
- The path formats in voc_train_lst.txt and voc_val_lst.txt are different, you can run create_train_lst.py to generate train_lst.txt in data dir for VOC2012. As follow:
```python
python src/dataset/create_train_lst.py --data_dir [DATA_DIR]
```
- [ADE20K Dataset Website](http://groups.csail.mit.edu/vision/datasets/ADE20K/)
- It contains 22,210 finely annotated images split into training and testing sets with 20,210 and 2,000 images respectively.
- The ADE20k directory structure is as follows:
......
# Copyright 2022 Huawei Technologies Co., Ltd
#
# 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.
# ============================================================================
"""generate train_lst.txt"""
import os
import argparse
def _parser_args():
parser = argparse.ArgumentParser('dataset list generator')
parser.add_argument("--data_dir", type=str, default='', help="VOC2012 data dir")
return parser.parse_args()
def _get_data_list(data_list_file):
with open(data_list_file, 'r') as f:
return f.readlines()
def main():
args = _parser_args()
data_dir = args.data_dir
voc_train_lst_txt = os.path.join(data_dir, 'voc_train_lst.txt')
train_lst_txt = os.path.join(data_dir, 'train_lst.txt')
voc_train_data_lst = _get_data_list(voc_train_lst_txt)
with open(train_lst_txt, 'w') as f:
for line in voc_train_data_lst:
img_, anno_ = (os.path.join('VOCdevkit/VOC2012', i.strip()) for i in line.split())
f.write(f'{img_} {anno_}\n')
print('generating voc train list success.')
if __name__ == "__main__":
main()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment