Skip to content

Commit 8c6d0d2

Browse files
authored
Dev (#242)
* refactor dataset * add customer dataset and associated config file * add script of check dataset information * modify script of check dataset * format * gitignore
1 parent a54e37a commit 8c6d0d2

16 files changed

+189
-30
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ venv.bak/
104104

105105

106106
## Coin:
107-
data
108-
data/
109107
play.py
110108
preprocess_data.py
111109
res/

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ frankfurt_000001_079206_leftImg8bit.png,frankfurt_000001_079206_gtFine_labelIds.
109109
...
110110
```
111111
Each line is a pair of training sample and ground truth image path, which are separated by a single comma `,`.
112-
Then you need to change the field of `im_root` and `train/val_im_anns` in the configuration files. If you found what shows in `cityscapes_cv2.py` is not clear, you can also see `coco.py`.
112+
113+
I recommand you to check the information of your dataset with the script:
114+
```
115+
$ python tools/check_dataset_info.py --im_root /path/to/your/data_root --im_anns /path/to/your/anno_file
116+
```
117+
This will print some of the information of your dataset.
118+
119+
Then you need to change the field of `im_root` and `train/val_im_anns` in the config file. I prepared a demo config file for you named [`bisenet_customer.py`](./configs/bisenet_customer.py). You can start from this conig file.
113120

114121

115122
## train

configs/bisenet_customer.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
cfg = dict(
3+
model_type='bisenetv1',
4+
n_cats=20,
5+
num_aux_heads=2,
6+
lr_start=1e-2,
7+
weight_decay=5e-4,
8+
warmup_iters=1000,
9+
max_iter=80000,
10+
dataset='CustomerDataset',
11+
im_root='./datasets/cityscapes',
12+
train_im_anns='./datasets/cityscapes/train.txt',
13+
val_im_anns='./datasets/cityscapes/val.txt',
14+
scales=[0.75, 2.],
15+
cropsize=[512, 512],
16+
eval_crop=[512, 512],
17+
eval_scales=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
18+
ims_per_gpu=8,
19+
eval_ims_per_gpu=2,
20+
use_fp16=True,
21+
use_sync_bn=False,
22+
respth='./res',
23+
)

lib/data/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
from .get_dataloader import get_data_loader

lib/base_dataset.py renamed to lib/data/base_dataset.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import cv2
1212
import numpy as np
1313

14-
from lib.sampler import RepeatedDistSampler
1514

1615

1716

lib/cityscapes_cv2.py renamed to lib/data/cityscapes_cv2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import cv2
1212
import numpy as np
1313

14-
import lib.transform_cv2 as T
15-
from lib.base_dataset import BaseDataset
14+
import lib.data.transform_cv2 as T
15+
from lib.data.base_dataset import BaseDataset
1616

1717

1818
labels_info = [

lib/coco.py renamed to lib/data/coco.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
import cv2
1212
import numpy as np
1313

14-
import lib.transform_cv2 as T
15-
from lib.sampler import RepeatedDistSampler
16-
from lib.base_dataset import BaseDataset
14+
import lib.data.transform_cv2 as T
15+
from lib.data.base_dataset import BaseDataset
1716

1817
'''
1918
91(thing) + 91(stuff) = 182 classes, label proportions are:
@@ -51,6 +50,7 @@ def __init__(self, dataroot, annpath, trans_func=None, mode='train'):
5150
super(CocoStuff, self).__init__(
5251
dataroot, annpath, trans_func, mode)
5352
self.n_cats = 171 # 91 stuff, 91 thing, 11 of thing have no annos
53+
self.lb_ignore = 255
5454

5555
## label mapping, remove non-existing labels
5656
missing = [11, 25, 28, 29, 44, 65, 67, 68, 70, 82, 90]

lib/data/customer_dataset.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/python
2+
# -*- encoding: utf-8 -*-
3+
4+
5+
import lib.data.transform_cv2 as T
6+
from lib.data.base_dataset import BaseDataset
7+
8+
9+
class CustomerDataset(BaseDataset):
10+
11+
def __init__(self, dataroot, annpath, trans_func=None, mode='train'):
12+
super(CustomerDataset, self).__init__(
13+
dataroot, annpath, trans_func, mode)
14+
self.lb_ignore = 255
15+
16+
self.to_tensor = T.ToTensor(
17+
mean=(0.4, 0.4, 0.4), # rgb
18+
std=(0.2, 0.2, 0.2),
19+
)
20+
21+

lib/get_dataloader.py renamed to lib/data/get_dataloader.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
from torch.utils.data import Dataset, DataLoader
44
import torch.distributed as dist
55

6-
import lib.transform_cv2 as T
7-
from lib.sampler import RepeatedDistSampler
8-
from lib.cityscapes_cv2 import CityScapes
9-
from lib.coco import CocoStuff
6+
import lib.data.transform_cv2 as T
7+
from lib.data.sampler import RepeatedDistSampler
8+
9+
from lib.data.cityscapes_cv2 import CityScapes
10+
from lib.data.coco import CocoStuff
11+
from lib.data.customer_dataset import CustomerDataset
1012

1113

1214

File renamed without changes.

0 commit comments

Comments
 (0)