Upload 2805 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +9 -0
- FoodSeg103/.DS_Store +0 -0
- FoodSeg103/.dev/gather_models.py +197 -0
- FoodSeg103/.dev/upload_modelzoo.py +44 -0
- FoodSeg103/.gitignore +117 -0
- FoodSeg103/.pre-commit-config.yaml +40 -0
- FoodSeg103/.readthedocs.yml +7 -0
- FoodSeg103/.tags +0 -0
- FoodSeg103/.tags_sorted_by_file +0 -0
- FoodSeg103/LICENSE +203 -0
- FoodSeg103/README.md +119 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.DS_Store +0 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.dev/gather_models.py +197 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.dev/upload_modelzoo.py +44 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/CODE_OF_CONDUCT.md +76 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/CONTRIBUTING.md +57 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/ISSUE_TEMPLATE/config.yml +6 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/ISSUE_TEMPLATE/error-report.md +48 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/ISSUE_TEMPLATE/general_questions.md +8 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/workflows/build.yml +98 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/workflows/deploy.yml +22 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.gitignore +117 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.pre-commit-config.yaml +40 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.readthedocs.yml +7 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/LICENSE +220 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/README.md +95 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/ade20k.py +54 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/chase_db1.py +59 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/cityscapes.py +54 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/cityscapes_769x769.py +35 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/drive.py +59 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/hrf.py +59 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/pascal_context.py +60 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/pascal_voc12.py +57 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/pascal_voc12_aug.py +9 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/stare.py +59 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/default_runtime.py +14 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/ann_r50-d8.py +46 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/apcnet_r50-d8.py +44 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/ccnet_r50-d8.py +44 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/cgnet.py +35 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/danet_r50-d8.py +44 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/deeplabv3_r50-d8.py +44 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/deeplabv3_unet_s5-d16.py +50 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/deeplabv3plus_r50-d8.py +46 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/dmnet_r50-d8.py +44 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/dnl_r50-d8.py +46 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/emanet_r50-d8.py +47 -0
- FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/encnet_r50-d8.py +48 -0
.gitattributes
CHANGED
@@ -33,3 +33,12 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
FoodSeg103/data/FoodSeg103/Images/img_dir/train/00000399.jpg filter=lfs diff=lfs merge=lfs -text
|
37 |
+
FoodSeg103/data/FoodSeg103/Images/img_dir/train/00001520.jpg filter=lfs diff=lfs merge=lfs -text
|
38 |
+
FoodSeg103/data/FoodSeg103/Images/img_dir/train/00001905.jpg filter=lfs diff=lfs merge=lfs -text
|
39 |
+
FoodSeg103/data/FoodSeg103/Images/img_dir/train/00002559.jpg filter=lfs diff=lfs merge=lfs -text
|
40 |
+
FoodSeg103/data/FoodSeg103/Images/img_dir/train/00003337.jpg filter=lfs diff=lfs merge=lfs -text
|
41 |
+
FoodSeg103/data/FoodSeg103/Images/img_dir/train/00004114.jpg filter=lfs diff=lfs merge=lfs -text
|
42 |
+
FoodSeg103/data/FoodSeg103/Images/img_dir/train/00006307.jpg filter=lfs diff=lfs merge=lfs -text
|
43 |
+
FoodSeg103/demo/mmcv/docs/en/_static/flow_raw_images.png filter=lfs diff=lfs merge=lfs -text
|
44 |
+
FoodSeg103/demo/mmcv/docs/en/_static/flow_warp_diff.png filter=lfs diff=lfs merge=lfs -text
|
FoodSeg103/.DS_Store
ADDED
Binary file (10.2 kB). View file
|
|
FoodSeg103/.dev/gather_models.py
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import glob
|
3 |
+
import json
|
4 |
+
import os
|
5 |
+
import os.path as osp
|
6 |
+
import shutil
|
7 |
+
import subprocess
|
8 |
+
|
9 |
+
import mmcv
|
10 |
+
import torch
|
11 |
+
|
12 |
+
# build schedule look-up table to automatically find the final model
|
13 |
+
RESULTS_LUT = ['mIoU', 'mAcc', 'aAcc']
|
14 |
+
|
15 |
+
|
16 |
+
def process_checkpoint(in_file, out_file):
|
17 |
+
checkpoint = torch.load(in_file, map_location='cpu')
|
18 |
+
# remove optimizer for smaller file size
|
19 |
+
if 'optimizer' in checkpoint:
|
20 |
+
del checkpoint['optimizer']
|
21 |
+
# if it is necessary to remove some sensitive data in checkpoint['meta'],
|
22 |
+
# add the code here.
|
23 |
+
torch.save(checkpoint, out_file)
|
24 |
+
sha = subprocess.check_output(['sha256sum', out_file]).decode()
|
25 |
+
final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8])
|
26 |
+
subprocess.Popen(['mv', out_file, final_file])
|
27 |
+
return final_file
|
28 |
+
|
29 |
+
|
30 |
+
def get_final_iter(config):
|
31 |
+
iter_num = config.split('_')[-2]
|
32 |
+
assert iter_num.endswith('k')
|
33 |
+
return int(iter_num[:-1]) * 1000
|
34 |
+
|
35 |
+
|
36 |
+
def get_final_results(log_json_path, iter_num):
|
37 |
+
result_dict = dict()
|
38 |
+
with open(log_json_path, 'r') as f:
|
39 |
+
for line in f.readlines():
|
40 |
+
log_line = json.loads(line)
|
41 |
+
if 'mode' not in log_line.keys():
|
42 |
+
continue
|
43 |
+
|
44 |
+
if log_line['mode'] == 'train' and log_line['iter'] == iter_num:
|
45 |
+
result_dict['memory'] = log_line['memory']
|
46 |
+
|
47 |
+
if log_line['iter'] == iter_num:
|
48 |
+
result_dict.update({
|
49 |
+
key: log_line[key]
|
50 |
+
for key in RESULTS_LUT if key in log_line
|
51 |
+
})
|
52 |
+
return result_dict
|
53 |
+
|
54 |
+
|
55 |
+
def parse_args():
|
56 |
+
parser = argparse.ArgumentParser(description='Gather benchmarked models')
|
57 |
+
parser.add_argument(
|
58 |
+
'root',
|
59 |
+
type=str,
|
60 |
+
help='root path of benchmarked models to be gathered')
|
61 |
+
parser.add_argument(
|
62 |
+
'config',
|
63 |
+
type=str,
|
64 |
+
help='root path of benchmarked configs to be gathered')
|
65 |
+
parser.add_argument(
|
66 |
+
'out_dir',
|
67 |
+
type=str,
|
68 |
+
help='output path of gathered models to be stored')
|
69 |
+
parser.add_argument('out_file', type=str, help='the output json file name')
|
70 |
+
parser.add_argument(
|
71 |
+
'--filter', type=str, nargs='+', default=[], help='config filter')
|
72 |
+
parser.add_argument(
|
73 |
+
'--all', action='store_true', help='whether include .py and .log')
|
74 |
+
|
75 |
+
args = parser.parse_args()
|
76 |
+
return args
|
77 |
+
|
78 |
+
|
79 |
+
def main():
|
80 |
+
args = parse_args()
|
81 |
+
models_root = args.root
|
82 |
+
models_out = args.out_dir
|
83 |
+
config_name = args.config
|
84 |
+
mmcv.mkdir_or_exist(models_out)
|
85 |
+
|
86 |
+
# find all models in the root directory to be gathered
|
87 |
+
raw_configs = list(mmcv.scandir(config_name, '.py', recursive=True))
|
88 |
+
|
89 |
+
# filter configs that is not trained in the experiments dir
|
90 |
+
used_configs = []
|
91 |
+
for raw_config in raw_configs:
|
92 |
+
work_dir = osp.splitext(osp.basename(raw_config))[0]
|
93 |
+
if osp.exists(osp.join(models_root, work_dir)):
|
94 |
+
used_configs.append((work_dir, raw_config))
|
95 |
+
print(f'Find {len(used_configs)} models to be gathered')
|
96 |
+
|
97 |
+
# find final_ckpt and log file for trained each config
|
98 |
+
# and parse the best performance
|
99 |
+
model_infos = []
|
100 |
+
for used_config, raw_config in used_configs:
|
101 |
+
bypass = True
|
102 |
+
for p in args.filter:
|
103 |
+
if p in used_config:
|
104 |
+
bypass = False
|
105 |
+
break
|
106 |
+
if bypass:
|
107 |
+
continue
|
108 |
+
exp_dir = osp.join(models_root, used_config)
|
109 |
+
# check whether the exps is finished
|
110 |
+
final_iter = get_final_iter(used_config)
|
111 |
+
final_model = 'iter_{}.pth'.format(final_iter)
|
112 |
+
model_path = osp.join(exp_dir, final_model)
|
113 |
+
|
114 |
+
# skip if the model is still training
|
115 |
+
if not osp.exists(model_path):
|
116 |
+
print(f'{used_config} train not finished yet')
|
117 |
+
continue
|
118 |
+
|
119 |
+
# get logs
|
120 |
+
log_json_paths = glob.glob(osp.join(exp_dir, '*.log.json'))
|
121 |
+
log_json_path = log_json_paths[0]
|
122 |
+
model_performance = None
|
123 |
+
for idx, _log_json_path in enumerate(log_json_paths):
|
124 |
+
model_performance = get_final_results(_log_json_path, final_iter)
|
125 |
+
if model_performance is not None:
|
126 |
+
log_json_path = _log_json_path
|
127 |
+
break
|
128 |
+
|
129 |
+
if model_performance is None:
|
130 |
+
print(f'{used_config} model_performance is None')
|
131 |
+
continue
|
132 |
+
|
133 |
+
model_time = osp.split(log_json_path)[-1].split('.')[0]
|
134 |
+
model_infos.append(
|
135 |
+
dict(
|
136 |
+
config=used_config,
|
137 |
+
raw_config=raw_config,
|
138 |
+
results=model_performance,
|
139 |
+
iters=final_iter,
|
140 |
+
model_time=model_time,
|
141 |
+
log_json_path=osp.split(log_json_path)[-1]))
|
142 |
+
|
143 |
+
# publish model for each checkpoint
|
144 |
+
publish_model_infos = []
|
145 |
+
for model in model_infos:
|
146 |
+
model_publish_dir = osp.join(models_out,
|
147 |
+
model['raw_config'].rstrip('.py'))
|
148 |
+
model_name = osp.split(model['config'])[-1].split('.')[0]
|
149 |
+
|
150 |
+
publish_model_path = osp.join(model_publish_dir,
|
151 |
+
model_name + '_' + model['model_time'])
|
152 |
+
trained_model_path = osp.join(models_root, model['config'],
|
153 |
+
'iter_{}.pth'.format(model['iters']))
|
154 |
+
if osp.exists(model_publish_dir):
|
155 |
+
for file in os.listdir(model_publish_dir):
|
156 |
+
if file.endswith('.pth'):
|
157 |
+
print(f'model {file} found')
|
158 |
+
model['model_path'] = osp.abspath(
|
159 |
+
osp.join(model_publish_dir, file))
|
160 |
+
break
|
161 |
+
if 'model_path' not in model:
|
162 |
+
print(f'dir {model_publish_dir} exists, no model found')
|
163 |
+
|
164 |
+
else:
|
165 |
+
mmcv.mkdir_or_exist(model_publish_dir)
|
166 |
+
|
167 |
+
# convert model
|
168 |
+
final_model_path = process_checkpoint(trained_model_path,
|
169 |
+
publish_model_path)
|
170 |
+
model['model_path'] = final_model_path
|
171 |
+
|
172 |
+
new_json_path = f'{model_name}-{model["log_json_path"]}'
|
173 |
+
# copy log
|
174 |
+
shutil.copy(
|
175 |
+
osp.join(models_root, model['config'], model['log_json_path']),
|
176 |
+
osp.join(model_publish_dir, new_json_path))
|
177 |
+
if args.all:
|
178 |
+
new_txt_path = new_json_path.rstrip('.json')
|
179 |
+
shutil.copy(
|
180 |
+
osp.join(models_root, model['config'],
|
181 |
+
model['log_json_path'].rstrip('.json')),
|
182 |
+
osp.join(model_publish_dir, new_txt_path))
|
183 |
+
|
184 |
+
if args.all:
|
185 |
+
# copy config to guarantee reproducibility
|
186 |
+
raw_config = osp.join(config_name, model['raw_config'])
|
187 |
+
mmcv.Config.fromfile(raw_config).dump(
|
188 |
+
osp.join(model_publish_dir, osp.basename(raw_config)))
|
189 |
+
|
190 |
+
publish_model_infos.append(model)
|
191 |
+
|
192 |
+
models = dict(models=publish_model_infos)
|
193 |
+
mmcv.dump(models, osp.join(models_out, args.out_file))
|
194 |
+
|
195 |
+
|
196 |
+
if __name__ == '__main__':
|
197 |
+
main()
|
FoodSeg103/.dev/upload_modelzoo.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import os
|
3 |
+
import os.path as osp
|
4 |
+
|
5 |
+
import oss2
|
6 |
+
|
7 |
+
ACCESS_KEY_ID = os.getenv('OSS_ACCESS_KEY_ID', None)
|
8 |
+
ACCESS_KEY_SECRET = os.getenv('OSS_ACCESS_KEY_SECRET', None)
|
9 |
+
BUCKET_NAME = 'openmmlab'
|
10 |
+
ENDPOINT = 'https://oss-accelerate.aliyuncs.com'
|
11 |
+
|
12 |
+
|
13 |
+
def parse_args():
|
14 |
+
parser = argparse.ArgumentParser(description='Upload models to OSS')
|
15 |
+
parser.add_argument('model_zoo', type=str, help='model_zoo input')
|
16 |
+
parser.add_argument(
|
17 |
+
'--dst-folder',
|
18 |
+
type=str,
|
19 |
+
default='mmsegmentation/v0.5',
|
20 |
+
help='destination folder')
|
21 |
+
args = parser.parse_args()
|
22 |
+
return args
|
23 |
+
|
24 |
+
|
25 |
+
def main():
|
26 |
+
args = parse_args()
|
27 |
+
model_zoo = args.model_zoo
|
28 |
+
dst_folder = args.dst_folder
|
29 |
+
bucket = oss2.Bucket(
|
30 |
+
oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET), ENDPOINT, BUCKET_NAME)
|
31 |
+
|
32 |
+
for root, dirs, files in os.walk(model_zoo):
|
33 |
+
for file in files:
|
34 |
+
file_path = osp.relpath(osp.join(root, file), model_zoo)
|
35 |
+
print(f'Uploading {file_path}')
|
36 |
+
|
37 |
+
oss2.resumable_upload(bucket, osp.join(dst_folder, file_path),
|
38 |
+
osp.join(model_zoo, file_path))
|
39 |
+
bucket.put_object_acl(
|
40 |
+
osp.join(dst_folder, file_path), oss2.OBJECT_ACL_PUBLIC_READ)
|
41 |
+
|
42 |
+
|
43 |
+
if __name__ == '__main__':
|
44 |
+
main()
|
FoodSeg103/.gitignore
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
*.egg-info/
|
24 |
+
.installed.cfg
|
25 |
+
*.egg
|
26 |
+
MANIFEST
|
27 |
+
|
28 |
+
# PyInstaller
|
29 |
+
# Usually these files are written by a python script from a template
|
30 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
31 |
+
*.manifest
|
32 |
+
*.spec
|
33 |
+
|
34 |
+
# Installer logs
|
35 |
+
pip-log.txt
|
36 |
+
pip-delete-this-directory.txt
|
37 |
+
|
38 |
+
# Unit test / coverage reports
|
39 |
+
htmlcov/
|
40 |
+
.tox/
|
41 |
+
.coverage
|
42 |
+
.coverage.*
|
43 |
+
.cache
|
44 |
+
nosetests.xml
|
45 |
+
coverage.xml
|
46 |
+
*.cover
|
47 |
+
.hypothesis/
|
48 |
+
.pytest_cache/
|
49 |
+
|
50 |
+
# Translations
|
51 |
+
*.mo
|
52 |
+
*.pot
|
53 |
+
|
54 |
+
# Django stuff:
|
55 |
+
*.log
|
56 |
+
local_settings.py
|
57 |
+
db.sqlite3
|
58 |
+
|
59 |
+
# Flask stuff:
|
60 |
+
instance/
|
61 |
+
.webassets-cache
|
62 |
+
|
63 |
+
# Scrapy stuff:
|
64 |
+
.scrapy
|
65 |
+
|
66 |
+
# Sphinx documentation
|
67 |
+
docs/_build/
|
68 |
+
|
69 |
+
# PyBuilder
|
70 |
+
target/
|
71 |
+
|
72 |
+
# Jupyter Notebook
|
73 |
+
.ipynb_checkpoints
|
74 |
+
|
75 |
+
# pyenv
|
76 |
+
.python-version
|
77 |
+
|
78 |
+
# celery beat schedule file
|
79 |
+
celerybeat-schedule
|
80 |
+
|
81 |
+
# SageMath parsed files
|
82 |
+
*.sage.py
|
83 |
+
|
84 |
+
# Environments
|
85 |
+
.env
|
86 |
+
.venv
|
87 |
+
env/
|
88 |
+
venv/
|
89 |
+
ENV/
|
90 |
+
env.bak/
|
91 |
+
venv.bak/
|
92 |
+
|
93 |
+
# Spyder project settings
|
94 |
+
.spyderproject
|
95 |
+
.spyproject
|
96 |
+
|
97 |
+
# Rope project settings
|
98 |
+
.ropeproject
|
99 |
+
|
100 |
+
# mkdocs documentation
|
101 |
+
/site
|
102 |
+
|
103 |
+
# mypy
|
104 |
+
.mypy_cache/
|
105 |
+
|
106 |
+
data
|
107 |
+
.vscode
|
108 |
+
.idea
|
109 |
+
|
110 |
+
# custom
|
111 |
+
*.pkl
|
112 |
+
*.pkl.json
|
113 |
+
*.log.json
|
114 |
+
work_dirs/
|
115 |
+
|
116 |
+
# Pytorch
|
117 |
+
*.pth
|
FoodSeg103/.pre-commit-config.yaml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
repos:
|
2 |
+
- repo: https://gitlab.com/pycqa/flake8.git
|
3 |
+
rev: 3.8.3
|
4 |
+
hooks:
|
5 |
+
- id: flake8
|
6 |
+
- repo: https://github.com/asottile/seed-isort-config
|
7 |
+
rev: v2.2.0
|
8 |
+
hooks:
|
9 |
+
- id: seed-isort-config
|
10 |
+
- repo: https://github.com/timothycrosley/isort
|
11 |
+
rev: 4.3.21
|
12 |
+
hooks:
|
13 |
+
- id: isort
|
14 |
+
- repo: https://github.com/pre-commit/mirrors-yapf
|
15 |
+
rev: v0.30.0
|
16 |
+
hooks:
|
17 |
+
- id: yapf
|
18 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
19 |
+
rev: v3.1.0
|
20 |
+
hooks:
|
21 |
+
- id: trailing-whitespace
|
22 |
+
- id: check-yaml
|
23 |
+
- id: end-of-file-fixer
|
24 |
+
- id: requirements-txt-fixer
|
25 |
+
- id: double-quote-string-fixer
|
26 |
+
- id: check-merge-conflict
|
27 |
+
- id: fix-encoding-pragma
|
28 |
+
args: ["--remove"]
|
29 |
+
- id: mixed-line-ending
|
30 |
+
args: ["--fix=lf"]
|
31 |
+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
32 |
+
rev: 2.1.4
|
33 |
+
hooks:
|
34 |
+
- id: markdownlint
|
35 |
+
args: ["-r", "~MD002,~MD013,~MD029,~MD033,~MD034,~MD036"]
|
36 |
+
- repo: https://github.com/myint/docformatter
|
37 |
+
rev: v1.3.1
|
38 |
+
hooks:
|
39 |
+
- id: docformatter
|
40 |
+
args: ["--in-place", "--wrap-descriptions", "79"]
|
FoodSeg103/.readthedocs.yml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2
|
2 |
+
|
3 |
+
python:
|
4 |
+
version: 3.7
|
5 |
+
install:
|
6 |
+
- requirements: requirements/docs.txt
|
7 |
+
- requirements: requirements/readthedocs.txt
|
FoodSeg103/.tags
ADDED
The diff for this file is too large to render.
See raw diff
|
|
FoodSeg103/.tags_sorted_by_file
ADDED
The diff for this file is too large to render.
See raw diff
|
|
FoodSeg103/LICENSE
ADDED
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright 2020 The MMSegmentation Authors. All rights reserved.
|
2 |
+
|
3 |
+
Apache License
|
4 |
+
Version 2.0, January 2004
|
5 |
+
http://www.apache.org/licenses/
|
6 |
+
|
7 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8 |
+
|
9 |
+
1. Definitions.
|
10 |
+
|
11 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
12 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
13 |
+
|
14 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
15 |
+
the copyright owner that is granting the License.
|
16 |
+
|
17 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
18 |
+
other entities that control, are controlled by, or are under common
|
19 |
+
control with that entity. For the purposes of this definition,
|
20 |
+
"control" means (i) the power, direct or indirect, to cause the
|
21 |
+
direction or management of such entity, whether by contract or
|
22 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
23 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
24 |
+
|
25 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
26 |
+
exercising permissions granted by this License.
|
27 |
+
|
28 |
+
"Source" form shall mean the preferred form for making modifications,
|
29 |
+
including but not limited to software source code, documentation
|
30 |
+
source, and configuration files.
|
31 |
+
|
32 |
+
"Object" form shall mean any form resulting from mechanical
|
33 |
+
transformation or translation of a Source form, including but
|
34 |
+
not limited to compiled object code, generated documentation,
|
35 |
+
and conversions to other media types.
|
36 |
+
|
37 |
+
"Work" shall mean the work of authorship, whether in Source or
|
38 |
+
Object form, made available under the License, as indicated by a
|
39 |
+
copyright notice that is included in or attached to the work
|
40 |
+
(an example is provided in the Appendix below).
|
41 |
+
|
42 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
43 |
+
form, that is based on (or derived from) the Work and for which the
|
44 |
+
editorial revisions, annotations, elaborations, or other modifications
|
45 |
+
represent, as a whole, an original work of authorship. For the purposes
|
46 |
+
of this License, Derivative Works shall not include works that remain
|
47 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
48 |
+
the Work and Derivative Works thereof.
|
49 |
+
|
50 |
+
"Contribution" shall mean any work of authorship, including
|
51 |
+
the original version of the Work and any modifications or additions
|
52 |
+
to that Work or Derivative Works thereof, that is intentionally
|
53 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
54 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
55 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
56 |
+
means any form of electronic, verbal, or written communication sent
|
57 |
+
to the Licensor or its representatives, including but not limited to
|
58 |
+
communication on electronic mailing lists, source code control systems,
|
59 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
60 |
+
Licensor for the purpose of discussing and improving the Work, but
|
61 |
+
excluding communication that is conspicuously marked or otherwise
|
62 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
63 |
+
|
64 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
65 |
+
on behalf of whom a Contribution has been received by Licensor and
|
66 |
+
subsequently incorporated within the Work.
|
67 |
+
|
68 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
69 |
+
this License, each Contributor hereby grants to You a perpetual,
|
70 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
71 |
+
copyright license to reproduce, prepare Derivative Works of,
|
72 |
+
publicly display, publicly perform, sublicense, and distribute the
|
73 |
+
Work and such Derivative Works in Source or Object form.
|
74 |
+
|
75 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
76 |
+
this License, each Contributor hereby grants to You a perpetual,
|
77 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
78 |
+
(except as stated in this section) patent license to make, have made,
|
79 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
80 |
+
where such license applies only to those patent claims licensable
|
81 |
+
by such Contributor that are necessarily infringed by their
|
82 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
83 |
+
with the Work to which such Contribution(s) was submitted. If You
|
84 |
+
institute patent litigation against any entity (including a
|
85 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
86 |
+
or a Contribution incorporated within the Work constitutes direct
|
87 |
+
or contributory patent infringement, then any patent licenses
|
88 |
+
granted to You under this License for that Work shall terminate
|
89 |
+
as of the date such litigation is filed.
|
90 |
+
|
91 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
92 |
+
Work or Derivative Works thereof in any medium, with or without
|
93 |
+
modifications, and in Source or Object form, provided that You
|
94 |
+
meet the following conditions:
|
95 |
+
|
96 |
+
(a) You must give any other recipients of the Work or
|
97 |
+
Derivative Works a copy of this License; and
|
98 |
+
|
99 |
+
(b) You must cause any modified files to carry prominent notices
|
100 |
+
stating that You changed the files; and
|
101 |
+
|
102 |
+
(c) You must retain, in the Source form of any Derivative Works
|
103 |
+
that You distribute, all copyright, patent, trademark, and
|
104 |
+
attribution notices from the Source form of the Work,
|
105 |
+
excluding those notices that do not pertain to any part of
|
106 |
+
the Derivative Works; and
|
107 |
+
|
108 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
109 |
+
distribution, then any Derivative Works that You distribute must
|
110 |
+
include a readable copy of the attribution notices contained
|
111 |
+
within such NOTICE file, excluding those notices that do not
|
112 |
+
pertain to any part of the Derivative Works, in at least one
|
113 |
+
of the following places: within a NOTICE text file distributed
|
114 |
+
as part of the Derivative Works; within the Source form or
|
115 |
+
documentation, if provided along with the Derivative Works; or,
|
116 |
+
within a display generated by the Derivative Works, if and
|
117 |
+
wherever such third-party notices normally appear. The contents
|
118 |
+
of the NOTICE file are for informational purposes only and
|
119 |
+
do not modify the License. You may add Your own attribution
|
120 |
+
notices within Derivative Works that You distribute, alongside
|
121 |
+
or as an addendum to the NOTICE text from the Work, provided
|
122 |
+
that such additional attribution notices cannot be construed
|
123 |
+
as modifying the License.
|
124 |
+
|
125 |
+
You may add Your own copyright statement to Your modifications and
|
126 |
+
may provide additional or different license terms and conditions
|
127 |
+
for use, reproduction, or distribution of Your modifications, or
|
128 |
+
for any such Derivative Works as a whole, provided Your use,
|
129 |
+
reproduction, and distribution of the Work otherwise complies with
|
130 |
+
the conditions stated in this License.
|
131 |
+
|
132 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
133 |
+
any Contribution intentionally submitted for inclusion in the Work
|
134 |
+
by You to the Licensor shall be under the terms and conditions of
|
135 |
+
this License, without any additional terms or conditions.
|
136 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
137 |
+
the terms of any separate license agreement you may have executed
|
138 |
+
with Licensor regarding such Contributions.
|
139 |
+
|
140 |
+
6. Trademarks. This License does not grant permission to use the trade
|
141 |
+
names, trademarks, service marks, or product names of the Licensor,
|
142 |
+
except as required for reasonable and customary use in describing the
|
143 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
144 |
+
|
145 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
146 |
+
agreed to in writing, Licensor provides the Work (and each
|
147 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
148 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
149 |
+
implied, including, without limitation, any warranties or conditions
|
150 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
151 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
152 |
+
appropriateness of using or redistributing the Work and assume any
|
153 |
+
risks associated with Your exercise of permissions under this License.
|
154 |
+
|
155 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
156 |
+
whether in tort (including negligence), contract, or otherwise,
|
157 |
+
unless required by applicable law (such as deliberate and grossly
|
158 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
159 |
+
liable to You for damages, including any direct, indirect, special,
|
160 |
+
incidental, or consequential damages of any character arising as a
|
161 |
+
result of this License or out of the use or inability to use the
|
162 |
+
Work (including but not limited to damages for loss of goodwill,
|
163 |
+
work stoppage, computer failure or malfunction, or any and all
|
164 |
+
other commercial damages or losses), even if such Contributor
|
165 |
+
has been advised of the possibility of such damages.
|
166 |
+
|
167 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
168 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
169 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
170 |
+
or other liability obligations and/or rights consistent with this
|
171 |
+
License. However, in accepting such obligations, You may act only
|
172 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
173 |
+
of any other Contributor, and only if You agree to indemnify,
|
174 |
+
defend, and hold each Contributor harmless for any liability
|
175 |
+
incurred by, or claims asserted against, such Contributor by reason
|
176 |
+
of your accepting any such warranty or additional liability.
|
177 |
+
|
178 |
+
END OF TERMS AND CONDITIONS
|
179 |
+
|
180 |
+
APPENDIX: How to apply the Apache License to your work.
|
181 |
+
|
182 |
+
To apply the Apache License to your work, attach the following
|
183 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
184 |
+
replaced with your own identifying information. (Don't include
|
185 |
+
the brackets!) The text should be enclosed in the appropriate
|
186 |
+
comment syntax for the file format. We also recommend that a
|
187 |
+
file or class name and description of purpose be included on the
|
188 |
+
same "printed page" as the copyright notice for easier
|
189 |
+
identification within third-party archives.
|
190 |
+
|
191 |
+
Copyright 2020 The MMSegmentation Authors.
|
192 |
+
|
193 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
194 |
+
you may not use this file except in compliance with the License.
|
195 |
+
You may obtain a copy of the License at
|
196 |
+
|
197 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
198 |
+
|
199 |
+
Unless required by applicable law or agreed to in writing, software
|
200 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
201 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
202 |
+
See the License for the specific language governing permissions and
|
203 |
+
limitations under the License.
|
FoodSeg103/README.md
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# A Large-Scale Benchmark for Food Image Segmentation
|
2 |
+
|
3 |
+
By [Xiongwei Wu](http://xiongweiwu.github.io/), [Xin Fu](https://xinfu607.github.io/), Ying Liu, [Ee-Peng Lim](http://www.mysmu.edu/faculty/eplim/), [Steven C.H. Hoi](https://sites.google.com/view/stevenhoi/home/), [Qianru Sun](https://qianrusun.com/).
|
4 |
+
|
5 |
+
|
6 |
+
<div align="center">
|
7 |
+
<img src="resources/foodseg103.png" width="800"/>
|
8 |
+
</div>
|
9 |
+
<br />
|
10 |
+
|
11 |
+
## Introduction
|
12 |
+
|
13 |
+
We build a new food image dataset FoodSeg103 containing 7,118 images. We annotate these images with 104 ingredient classes and each image has an average of 6 ingredient labels and pixel-wise masks.
|
14 |
+
In addition, we propose a multi-modality pre-training approach called ReLeM that explicitly equips a segmentation model with rich and semantic food knowledge.
|
15 |
+
|
16 |
+
In this software, we use three popular semantic segmentation methods (i.e., Dilated Convolution based, Feature Pyramid based, and Vision Transformer based) as baselines, and evaluate them as well as ReLeM on our new datasets. We believe that the FoodSeg103 and the pre-trained models using ReLeM can serve as a benchmark to facilitate future works on fine-grained food image understanding.
|
17 |
+
|
18 |
+
Please refer our [paper](https://arxiv.org/abs/2105.05409) and our [homepage](https://xiongweiwu.github.io/foodseg103.html) for more details.
|
19 |
+
|
20 |
+
## License
|
21 |
+
|
22 |
+
This project is released under the [Apache 2.0 license](LICENSE).
|
23 |
+
|
24 |
+
|
25 |
+
## Installation
|
26 |
+
|
27 |
+
Please refer to [get_started.md](docs/get_started.md#installation) for installation.
|
28 |
+
|
29 |
+
## Dataset
|
30 |
+
|
31 |
+
Please download the file from [url](https://research.larc.smu.edu.sg/downloads/datarepo/FoodSeg103.zip) and unzip the data in ./data folder (./data/FoodSeg103/), with passwd: LARCdataset9947
|
32 |
+
|
33 |
+
## Leaderboard
|
34 |
+
|
35 |
+
Please refer to [leaderboard](https://paperswithcode.com/dataset/foodseg103) in paperwithcode website.
|
36 |
+
|
37 |
+
## Benchmark and model zoo
|
38 |
+
|
39 |
+
:exclamation::exclamation::exclamation: **We have finished the course so the models are available again. Please download the trained models from THIS [link](https://smu-my.sharepoint.com/:u:/g/personal/xwwu_smu_edu_sg/EWBcCC3QrO9LthKX66QCzyoBhFU7PHXKcHhh1lgIC98uKw?e=bHT7vM):eyes: .**
|
40 |
+
|
41 |
+
Encoder | Decoder | Crop Size | Batch Size |mIoU | mAcc | Link
|
42 |
+
--- |:---:|:---:|:---:|:---:|:---:|:---:
|
43 |
+
R-50 | [FPN](https://arxiv.org/abs/1901.02446) | 512x1024 | 8 | 27.8 | 38.2 | [Model+Config](https://drive.google.com/drive/folders/1CQ5CXxASAoobj7bKqyuvazkeusqMAM4F?usp=sharing)
|
44 |
+
ReLeM-R-50 | FPN | 512x1024 | 8 | 29.1 | 39.8 | [Model+Config](https://drive.google.com/drive/folders/1m7N2EE8jkX67a0lD6GZ4NQgr4gEcWpDU?usp=sharing)
|
45 |
+
R-50 | [CCNet](https://arxiv.org/abs/1811.11721) | 512x1024 | 8 | 35.5 | 45.3 | [Model+Config](https://drive.google.com/drive/folders/1pNPbtrGqCq_Zlina2PCs6X8bIvY9ZZxG?usp=sharing)
|
46 |
+
ReLeM-R-50 | CCNet | 512x1024 | 8 | 36.8 | 47.4 | [Model+Config](https://drive.google.com/drive/folders/1FWwxAsZzDnBbDBEbohqOA8htyWgMLM4U?usp=sharing)
|
47 |
+
[PVT-S](https://arxiv.org/abs/2102.12122) | FPN | 512x1024 | 8 | 31.3 | 43.0 | Model+Config
|
48 |
+
ReLeM-PVT-S | FPN | 512x1024 | 8 | 32.0 | 44.1 | Model+Config
|
49 |
+
[ViT-16/B](https://openreview.net/forum?id=YicbFdNTTy) | [Naive](https://arxiv.org/abs/2012.15840) | 768x768 | 4 | 41.3 | 52.7 | [Model+Config](https://drive.google.com/drive/folders/19b3VG906CA-5kQFaJVk5U6kDxnw9HcWL?usp=sharing)
|
50 |
+
ReLeM-ViT-16/B | Naive | 768x768 | 4 | 43.9 | 57.0 | [Model+Config](https://drive.google.com/drive/folders/10yKiu8aMeTGphU2CKT2ybeAC3ezgDnXP?usp=sharing)
|
51 |
+
ViT-16/B | PUP | 768x768 | 4 | 38.5 | 49.1 | Model+Config
|
52 |
+
ReLeM-ViT-16/B | PUP | 768x768 | 4 | 42.5 | 53.9 | Model+Config
|
53 |
+
ViT-16/B | [MLA](https://arxiv.org/abs/2012.15840) | 768x768 | 4 | 45.1 | 57.4 | [Model+Config](https://drive.google.com/drive/folders/17Ht1HQDaBJmS0FXaXGjHk0VQNhAJxrlF?usp=sharing)
|
54 |
+
ReLeM-ViT-16/B | MLA | 768x768 | 4 | 43.3 | 55.9 | [Model+Config](https://drive.google.com/drive/folders/12OlkStefNmELNLo-xJqc-lE-kPZ7DvPV?usp=sharing)
|
55 |
+
[ViT-16/L](https://openreview.net/forum?id=YicbFdNTTy) | MLA | 768x768 | 4 | 44.5 | 56.6 | [Model+Config](https://drive.google.com/drive/folders/1PS4uh2zktNc0hh-mSLZkRTqgNnkfh7xu?usp=sharing)
|
56 |
+
[Swin-S](https://arxiv.org/abs/2103.14030) | [UperNet](https://arxiv.org/abs/1807.10221) | 512x1024 | 8 | 41.6 | 53.6 | [Model+Config](https://drive.google.com/drive/folders/1E5fZga8h65dNZCX1m8zywvB8MwrleFNg?usp=sharing)
|
57 |
+
[Swin-B](https://arxiv.org/abs/2103.14030) | UperNet | 512x1024 | 8 | 41.2 | 53.9 | [Model+Config](https://drive.google.com/drive/folders/1kqOsH51h1pa-88tbFVUV3mmzTNCGzqd0?usp=sharing)
|
58 |
+
|
59 |
+
|
60 |
+
[1] *We do not include the implementation of [swin](https://arxiv.org/abs/2103.14030) in this software. You can use the official [implementation](https://github.com/SwinTransformer/Swin-Transformer-Semantic-Segmentation) based on our provided models.* \
|
61 |
+
[2] *We use Step-wise learning policy to train PVT model since we found this policy can yield higher performance, and for other baselines we adopt the default settings.* \
|
62 |
+
[3] *We use Recipe1M to train ReLeM-PVT-S while other ReLeM models are trained with Recipe1M+ due to time limitation.*
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
## Train & Test
|
67 |
+
|
68 |
+
Train script:
|
69 |
+
|
70 |
+
```
|
71 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port=${PORT:-300} tools/train.py --config [config] --work-dir [work-dir] --launcher pytorch
|
72 |
+
```
|
73 |
+
|
74 |
+
Exmaple:
|
75 |
+
|
76 |
+
```
|
77 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port=${PORT:-300} tools/train.py --config configs/foodnet/SETR_Naive_768x768_80k_base_RM.py --work-dir checkpoints/SETR_Naive_ReLeM --launcher pytorch
|
78 |
+
```
|
79 |
+
|
80 |
+
Test script:
|
81 |
+
|
82 |
+
```
|
83 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port=${PORT:-999} tools/test.py [config] [weights] --launcher pytorch --eval mIoU
|
84 |
+
```
|
85 |
+
|
86 |
+
Example:
|
87 |
+
|
88 |
+
```
|
89 |
+
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.launch --nproc_per_node=4 --master_port=${PORT:-999} tools/test.py checkpoints/SETR_Naive_ReLeM/SETR_Naive_768x768_80k_base_RM.py checkpoints/SETR_Naive_ReLeM/iter_80000.pth --launcher pytorch --eval mIoU
|
90 |
+
```
|
91 |
+
|
92 |
+
## ReLeM
|
93 |
+
We train recipe information based on the implementation of [im2recipe](https://github.com/torralba-lab/im2recipe-Pytorch) with small modifications, which is trained on [Recipe1M+](http://pic2recipe.csail.mit.edu/) dataset (test images of FoodSeg103 are removed). I may upload the lmdb file later due to the huge datasize (>35G).
|
94 |
+
|
95 |
+
It takes about 2~3 weeks to train a ReLeM ViT-Base model with 8 Tesla-V100 cards, so I strongly recommend you use my pre-trained models([link](https://drive.google.com/drive/folders/1LRCHxeMuCXMb68I1XFI8q-aQ2cCyUx_r?usp=sharing)).
|
96 |
+
|
97 |
+
|
98 |
+
## Citation
|
99 |
+
|
100 |
+
If you find this project useful in your research, please consider cite:
|
101 |
+
|
102 |
+
```latex
|
103 |
+
@inproceedings{wu2021foodseg,
|
104 |
+
title={A Large-Scale Benchmark for Food Image Segmentation},
|
105 |
+
author={Wu, Xiongwei and Fu, Xin and Liu, Ying and Lim, Ee-Peng and Hoi, Steven CH and Sun, Qianru},
|
106 |
+
booktitle={Proceedings of ACM international conference on Multimedia},
|
107 |
+
year={2021}
|
108 |
+
}
|
109 |
+
```
|
110 |
+
|
111 |
+
## Other Issues
|
112 |
+
|
113 |
+
If you meet other issues in using the software, you can check the original mmsegmentation (see [doc](https://mmsegmentation.readthedocs.io/) for more details).
|
114 |
+
|
115 |
+
|
116 |
+
## Acknowledgement
|
117 |
+
|
118 |
+
The segmentation software in this project was developed mainly by extending the [segmentation](https://github.com/open-mmlab/mmsegmentation/).
|
119 |
+
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.DS_Store
ADDED
Binary file (8.2 kB). View file
|
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.dev/gather_models.py
ADDED
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import glob
|
3 |
+
import json
|
4 |
+
import os
|
5 |
+
import os.path as osp
|
6 |
+
import shutil
|
7 |
+
import subprocess
|
8 |
+
|
9 |
+
import mmcv
|
10 |
+
import torch
|
11 |
+
|
12 |
+
# build schedule look-up table to automatically find the final model
|
13 |
+
RESULTS_LUT = ['mIoU', 'mAcc', 'aAcc']
|
14 |
+
|
15 |
+
|
16 |
+
def process_checkpoint(in_file, out_file):
|
17 |
+
checkpoint = torch.load(in_file, map_location='cpu')
|
18 |
+
# remove optimizer for smaller file size
|
19 |
+
if 'optimizer' in checkpoint:
|
20 |
+
del checkpoint['optimizer']
|
21 |
+
# if it is necessary to remove some sensitive data in checkpoint['meta'],
|
22 |
+
# add the code here.
|
23 |
+
torch.save(checkpoint, out_file)
|
24 |
+
sha = subprocess.check_output(['sha256sum', out_file]).decode()
|
25 |
+
final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8])
|
26 |
+
subprocess.Popen(['mv', out_file, final_file])
|
27 |
+
return final_file
|
28 |
+
|
29 |
+
|
30 |
+
def get_final_iter(config):
|
31 |
+
iter_num = config.split('_')[-2]
|
32 |
+
assert iter_num.endswith('k')
|
33 |
+
return int(iter_num[:-1]) * 1000
|
34 |
+
|
35 |
+
|
36 |
+
def get_final_results(log_json_path, iter_num):
|
37 |
+
result_dict = dict()
|
38 |
+
with open(log_json_path, 'r') as f:
|
39 |
+
for line in f.readlines():
|
40 |
+
log_line = json.loads(line)
|
41 |
+
if 'mode' not in log_line.keys():
|
42 |
+
continue
|
43 |
+
|
44 |
+
if log_line['mode'] == 'train' and log_line['iter'] == iter_num:
|
45 |
+
result_dict['memory'] = log_line['memory']
|
46 |
+
|
47 |
+
if log_line['iter'] == iter_num:
|
48 |
+
result_dict.update({
|
49 |
+
key: log_line[key]
|
50 |
+
for key in RESULTS_LUT if key in log_line
|
51 |
+
})
|
52 |
+
return result_dict
|
53 |
+
|
54 |
+
|
55 |
+
def parse_args():
|
56 |
+
parser = argparse.ArgumentParser(description='Gather benchmarked models')
|
57 |
+
parser.add_argument(
|
58 |
+
'root',
|
59 |
+
type=str,
|
60 |
+
help='root path of benchmarked models to be gathered')
|
61 |
+
parser.add_argument(
|
62 |
+
'config',
|
63 |
+
type=str,
|
64 |
+
help='root path of benchmarked configs to be gathered')
|
65 |
+
parser.add_argument(
|
66 |
+
'out_dir',
|
67 |
+
type=str,
|
68 |
+
help='output path of gathered models to be stored')
|
69 |
+
parser.add_argument('out_file', type=str, help='the output json file name')
|
70 |
+
parser.add_argument(
|
71 |
+
'--filter', type=str, nargs='+', default=[], help='config filter')
|
72 |
+
parser.add_argument(
|
73 |
+
'--all', action='store_true', help='whether include .py and .log')
|
74 |
+
|
75 |
+
args = parser.parse_args()
|
76 |
+
return args
|
77 |
+
|
78 |
+
|
79 |
+
def main():
|
80 |
+
args = parse_args()
|
81 |
+
models_root = args.root
|
82 |
+
models_out = args.out_dir
|
83 |
+
config_name = args.config
|
84 |
+
mmcv.mkdir_or_exist(models_out)
|
85 |
+
|
86 |
+
# find all models in the root directory to be gathered
|
87 |
+
raw_configs = list(mmcv.scandir(config_name, '.py', recursive=True))
|
88 |
+
|
89 |
+
# filter configs that is not trained in the experiments dir
|
90 |
+
used_configs = []
|
91 |
+
for raw_config in raw_configs:
|
92 |
+
work_dir = osp.splitext(osp.basename(raw_config))[0]
|
93 |
+
if osp.exists(osp.join(models_root, work_dir)):
|
94 |
+
used_configs.append((work_dir, raw_config))
|
95 |
+
print(f'Find {len(used_configs)} models to be gathered')
|
96 |
+
|
97 |
+
# find final_ckpt and log file for trained each config
|
98 |
+
# and parse the best performance
|
99 |
+
model_infos = []
|
100 |
+
for used_config, raw_config in used_configs:
|
101 |
+
bypass = True
|
102 |
+
for p in args.filter:
|
103 |
+
if p in used_config:
|
104 |
+
bypass = False
|
105 |
+
break
|
106 |
+
if bypass:
|
107 |
+
continue
|
108 |
+
exp_dir = osp.join(models_root, used_config)
|
109 |
+
# check whether the exps is finished
|
110 |
+
final_iter = get_final_iter(used_config)
|
111 |
+
final_model = 'iter_{}.pth'.format(final_iter)
|
112 |
+
model_path = osp.join(exp_dir, final_model)
|
113 |
+
|
114 |
+
# skip if the model is still training
|
115 |
+
if not osp.exists(model_path):
|
116 |
+
print(f'{used_config} train not finished yet')
|
117 |
+
continue
|
118 |
+
|
119 |
+
# get logs
|
120 |
+
log_json_paths = glob.glob(osp.join(exp_dir, '*.log.json'))
|
121 |
+
log_json_path = log_json_paths[0]
|
122 |
+
model_performance = None
|
123 |
+
for idx, _log_json_path in enumerate(log_json_paths):
|
124 |
+
model_performance = get_final_results(_log_json_path, final_iter)
|
125 |
+
if model_performance is not None:
|
126 |
+
log_json_path = _log_json_path
|
127 |
+
break
|
128 |
+
|
129 |
+
if model_performance is None:
|
130 |
+
print(f'{used_config} model_performance is None')
|
131 |
+
continue
|
132 |
+
|
133 |
+
model_time = osp.split(log_json_path)[-1].split('.')[0]
|
134 |
+
model_infos.append(
|
135 |
+
dict(
|
136 |
+
config=used_config,
|
137 |
+
raw_config=raw_config,
|
138 |
+
results=model_performance,
|
139 |
+
iters=final_iter,
|
140 |
+
model_time=model_time,
|
141 |
+
log_json_path=osp.split(log_json_path)[-1]))
|
142 |
+
|
143 |
+
# publish model for each checkpoint
|
144 |
+
publish_model_infos = []
|
145 |
+
for model in model_infos:
|
146 |
+
model_publish_dir = osp.join(models_out,
|
147 |
+
model['raw_config'].rstrip('.py'))
|
148 |
+
model_name = osp.split(model['config'])[-1].split('.')[0]
|
149 |
+
|
150 |
+
publish_model_path = osp.join(model_publish_dir,
|
151 |
+
model_name + '_' + model['model_time'])
|
152 |
+
trained_model_path = osp.join(models_root, model['config'],
|
153 |
+
'iter_{}.pth'.format(model['iters']))
|
154 |
+
if osp.exists(model_publish_dir):
|
155 |
+
for file in os.listdir(model_publish_dir):
|
156 |
+
if file.endswith('.pth'):
|
157 |
+
print(f'model {file} found')
|
158 |
+
model['model_path'] = osp.abspath(
|
159 |
+
osp.join(model_publish_dir, file))
|
160 |
+
break
|
161 |
+
if 'model_path' not in model:
|
162 |
+
print(f'dir {model_publish_dir} exists, no model found')
|
163 |
+
|
164 |
+
else:
|
165 |
+
mmcv.mkdir_or_exist(model_publish_dir)
|
166 |
+
|
167 |
+
# convert model
|
168 |
+
final_model_path = process_checkpoint(trained_model_path,
|
169 |
+
publish_model_path)
|
170 |
+
model['model_path'] = final_model_path
|
171 |
+
|
172 |
+
new_json_path = f'{model_name}-{model["log_json_path"]}'
|
173 |
+
# copy log
|
174 |
+
shutil.copy(
|
175 |
+
osp.join(models_root, model['config'], model['log_json_path']),
|
176 |
+
osp.join(model_publish_dir, new_json_path))
|
177 |
+
if args.all:
|
178 |
+
new_txt_path = new_json_path.rstrip('.json')
|
179 |
+
shutil.copy(
|
180 |
+
osp.join(models_root, model['config'],
|
181 |
+
model['log_json_path'].rstrip('.json')),
|
182 |
+
osp.join(model_publish_dir, new_txt_path))
|
183 |
+
|
184 |
+
if args.all:
|
185 |
+
# copy config to guarantee reproducibility
|
186 |
+
raw_config = osp.join(config_name, model['raw_config'])
|
187 |
+
mmcv.Config.fromfile(raw_config).dump(
|
188 |
+
osp.join(model_publish_dir, osp.basename(raw_config)))
|
189 |
+
|
190 |
+
publish_model_infos.append(model)
|
191 |
+
|
192 |
+
models = dict(models=publish_model_infos)
|
193 |
+
mmcv.dump(models, osp.join(models_out, args.out_file))
|
194 |
+
|
195 |
+
|
196 |
+
if __name__ == '__main__':
|
197 |
+
main()
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.dev/upload_modelzoo.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import os
|
3 |
+
import os.path as osp
|
4 |
+
|
5 |
+
import oss2
|
6 |
+
|
7 |
+
ACCESS_KEY_ID = os.getenv('OSS_ACCESS_KEY_ID', None)
|
8 |
+
ACCESS_KEY_SECRET = os.getenv('OSS_ACCESS_KEY_SECRET', None)
|
9 |
+
BUCKET_NAME = 'openmmlab'
|
10 |
+
ENDPOINT = 'https://oss-accelerate.aliyuncs.com'
|
11 |
+
|
12 |
+
|
13 |
+
def parse_args():
|
14 |
+
parser = argparse.ArgumentParser(description='Upload models to OSS')
|
15 |
+
parser.add_argument('model_zoo', type=str, help='model_zoo input')
|
16 |
+
parser.add_argument(
|
17 |
+
'--dst-folder',
|
18 |
+
type=str,
|
19 |
+
default='mmsegmentation/v0.5',
|
20 |
+
help='destination folder')
|
21 |
+
args = parser.parse_args()
|
22 |
+
return args
|
23 |
+
|
24 |
+
|
25 |
+
def main():
|
26 |
+
args = parse_args()
|
27 |
+
model_zoo = args.model_zoo
|
28 |
+
dst_folder = args.dst_folder
|
29 |
+
bucket = oss2.Bucket(
|
30 |
+
oss2.Auth(ACCESS_KEY_ID, ACCESS_KEY_SECRET), ENDPOINT, BUCKET_NAME)
|
31 |
+
|
32 |
+
for root, dirs, files in os.walk(model_zoo):
|
33 |
+
for file in files:
|
34 |
+
file_path = osp.relpath(osp.join(root, file), model_zoo)
|
35 |
+
print(f'Uploading {file_path}')
|
36 |
+
|
37 |
+
oss2.resumable_upload(bucket, osp.join(dst_folder, file_path),
|
38 |
+
osp.join(model_zoo, file_path))
|
39 |
+
bucket.put_object_acl(
|
40 |
+
osp.join(dst_folder, file_path), oss2.OBJECT_ACL_PUBLIC_READ)
|
41 |
+
|
42 |
+
|
43 |
+
if __name__ == '__main__':
|
44 |
+
main()
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributor Covenant Code of Conduct
|
2 |
+
|
3 |
+
## Our Pledge
|
4 |
+
|
5 |
+
In the interest of fostering an open and welcoming environment, we as
|
6 |
+
contributors and maintainers pledge to making participation in our project and
|
7 |
+
our community a harassment-free experience for everyone, regardless of age, body
|
8 |
+
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
9 |
+
level of experience, education, socio-economic status, nationality, personal
|
10 |
+
appearance, race, religion, or sexual identity and orientation.
|
11 |
+
|
12 |
+
## Our Standards
|
13 |
+
|
14 |
+
Examples of behavior that contributes to creating a positive environment
|
15 |
+
include:
|
16 |
+
|
17 |
+
* Using welcoming and inclusive language
|
18 |
+
* Being respectful of differing viewpoints and experiences
|
19 |
+
* Gracefully accepting constructive criticism
|
20 |
+
* Focusing on what is best for the community
|
21 |
+
* Showing empathy towards other community members
|
22 |
+
|
23 |
+
Examples of unacceptable behavior by participants include:
|
24 |
+
|
25 |
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26 |
+
advances
|
27 |
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28 |
+
* Public or private harassment
|
29 |
+
* Publishing others' private information, such as a physical or electronic
|
30 |
+
address, without explicit permission
|
31 |
+
* Other conduct which could reasonably be considered inappropriate in a
|
32 |
+
professional setting
|
33 |
+
|
34 |
+
## Our Responsibilities
|
35 |
+
|
36 |
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37 |
+
behavior and are expected to take appropriate and fair corrective action in
|
38 |
+
response to any instances of unacceptable behavior.
|
39 |
+
|
40 |
+
Project maintainers have the right and responsibility to remove, edit, or
|
41 |
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42 |
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43 |
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44 |
+
threatening, offensive, or harmful.
|
45 |
+
|
46 |
+
## Scope
|
47 |
+
|
48 |
+
This Code of Conduct applies both within project spaces and in public spaces
|
49 |
+
when an individual is representing the project or its community. Examples of
|
50 |
+
representing a project or community include using an official project e-mail
|
51 |
+
address, posting via an official social media account, or acting as an appointed
|
52 |
+
representative at an online or offline event. Representation of a project may be
|
53 |
+
further defined and clarified by project maintainers.
|
54 |
+
|
55 |
+
## Enforcement
|
56 |
+
|
57 |
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58 |
+
reported by contacting the project team at [email protected]. All
|
59 |
+
complaints will be reviewed and investigated and will result in a response that
|
60 |
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61 |
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62 |
+
Further details of specific enforcement policies may be posted separately.
|
63 |
+
|
64 |
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65 |
+
faith may face temporary or permanent repercussions as determined by other
|
66 |
+
members of the project's leadership.
|
67 |
+
|
68 |
+
## Attribution
|
69 |
+
|
70 |
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71 |
+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
72 |
+
|
73 |
+
[homepage]: https://www.contributor-covenant.org
|
74 |
+
|
75 |
+
For answers to common questions about this code of conduct, see
|
76 |
+
https://www.contributor-covenant.org/faq
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/CONTRIBUTING.md
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributing to mmsegmentation
|
2 |
+
|
3 |
+
All kinds of contributions are welcome, including but not limited to the following.
|
4 |
+
|
5 |
+
- Fixes (typo, bugs)
|
6 |
+
- New features and components
|
7 |
+
|
8 |
+
## Workflow
|
9 |
+
|
10 |
+
1. fork and pull the latest mmsegmentation
|
11 |
+
2. checkout a new branch (do not use master branch for PRs)
|
12 |
+
3. commit your changes
|
13 |
+
4. create a PR
|
14 |
+
|
15 |
+
Note
|
16 |
+
|
17 |
+
- If you plan to add some new features that involve large changes, it is encouraged to open an issue for discussion first.
|
18 |
+
- If you are the author of some papers and would like to include your method to mmsegmentation,
|
19 |
+
please contact Kai Chen (chenkaidev[at]gmail[dot]com). We will much appreciate your contribution.
|
20 |
+
|
21 |
+
## Code style
|
22 |
+
|
23 |
+
### Python
|
24 |
+
|
25 |
+
We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style.
|
26 |
+
|
27 |
+
We use the following tools for linting and formatting:
|
28 |
+
|
29 |
+
- [flake8](http://flake8.pycqa.org/en/latest/): linter
|
30 |
+
- [yapf](https://github.com/google/yapf): formatter
|
31 |
+
- [isort](https://github.com/timothycrosley/isort): sort imports
|
32 |
+
|
33 |
+
Style configurations of yapf and isort can be found in [setup.cfg](../setup.cfg) and [.isort.cfg](../.isort.cfg).
|
34 |
+
|
35 |
+
We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`,
|
36 |
+
fixes `end-of-files`, sorts `requirments.txt` automatically on every commit.
|
37 |
+
The config for a pre-commit hook is stored in [.pre-commit-config](../.pre-commit-config.yaml).
|
38 |
+
|
39 |
+
After you clone the repository, you will need to install initialize pre-commit hook.
|
40 |
+
|
41 |
+
```shell
|
42 |
+
pip install -U pre-commit
|
43 |
+
```
|
44 |
+
|
45 |
+
From the repository folder
|
46 |
+
|
47 |
+
```shell
|
48 |
+
pre-commit install
|
49 |
+
```
|
50 |
+
|
51 |
+
After this on every commit check code linters and formatter will be enforced.
|
52 |
+
|
53 |
+
>Before you create a PR, make sure that your code lints and is formatted by yapf.
|
54 |
+
|
55 |
+
### C++ and CUDA
|
56 |
+
|
57 |
+
We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/ISSUE_TEMPLATE/config.yml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
blank_issues_enabled: false
|
2 |
+
|
3 |
+
contact_links:
|
4 |
+
- name: MMSegmentation Documentation
|
5 |
+
url: https://mmsegmentation.readthedocs.io
|
6 |
+
about: Check the docs and FAQ to see if you question is already anwsered.
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/ISSUE_TEMPLATE/error-report.md
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Error report
|
3 |
+
about: Create a report to help us improve
|
4 |
+
title: ''
|
5 |
+
labels: ''
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
Thanks for your error report and we appreciate it a lot.
|
11 |
+
|
12 |
+
**Checklist**
|
13 |
+
|
14 |
+
1. I have searched related issues but cannot get the expected help.
|
15 |
+
2. The bug has not been fixed in the latest version.
|
16 |
+
|
17 |
+
**Describe the bug**
|
18 |
+
A clear and concise description of what the bug is.
|
19 |
+
|
20 |
+
**Reproduction**
|
21 |
+
|
22 |
+
1. What command or script did you run?
|
23 |
+
|
24 |
+
```none
|
25 |
+
A placeholder for the command.
|
26 |
+
```
|
27 |
+
|
28 |
+
2. Did you make any modifications on the code or config? Did you understand what you have modified?
|
29 |
+
3. What dataset did you use?
|
30 |
+
|
31 |
+
**Environment**
|
32 |
+
|
33 |
+
1. Please run `python mmseg/utils/collect_env.py` to collect necessary environment infomation and paste it here.
|
34 |
+
2. You may add addition that may be helpful for locating the problem, such as
|
35 |
+
- How you installed PyTorch [e.g., pip, conda, source]
|
36 |
+
- Other environment variables that may be related (such as `$PATH`, `$LD_LIBRARY_PATH`, `$PYTHONPATH`, etc.)
|
37 |
+
|
38 |
+
**Error traceback**
|
39 |
+
|
40 |
+
If applicable, paste the error trackback here.
|
41 |
+
|
42 |
+
```none
|
43 |
+
A placeholder for trackback.
|
44 |
+
```
|
45 |
+
|
46 |
+
**Bug fix**
|
47 |
+
|
48 |
+
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/ISSUE_TEMPLATE/feature_request.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Feature request
|
3 |
+
about: Suggest an idea for this project
|
4 |
+
title: ''
|
5 |
+
labels: ''
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
# Describe the feature
|
11 |
+
|
12 |
+
**Motivation**
|
13 |
+
A clear and concise description of the motivation of the feature.
|
14 |
+
Ex1. It is inconvenient when [....].
|
15 |
+
Ex2. There is a recent paper [....], which is very helpful for [....].
|
16 |
+
|
17 |
+
**Related resources**
|
18 |
+
If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful.
|
19 |
+
|
20 |
+
**Additional context**
|
21 |
+
Add any other context or screenshots about the feature request here.
|
22 |
+
If you would like to implement the feature and create a PR, please leave a comment here and that would be much appreciated.
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/ISSUE_TEMPLATE/general_questions.md
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: General questions
|
3 |
+
about: Ask general questions to get help
|
4 |
+
title: ''
|
5 |
+
labels: ''
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/workflows/build.yml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: build
|
2 |
+
|
3 |
+
on: [push, pull_request]
|
4 |
+
|
5 |
+
jobs:
|
6 |
+
lint:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
steps:
|
9 |
+
- uses: actions/checkout@v2
|
10 |
+
- name: Set up Python 3.7
|
11 |
+
uses: actions/setup-python@v1
|
12 |
+
with:
|
13 |
+
python-version: 3.7
|
14 |
+
- name: Install pre-commit hook
|
15 |
+
run: |
|
16 |
+
pip install pre-commit
|
17 |
+
pre-commit install
|
18 |
+
- name: Linting
|
19 |
+
run: pre-commit run --all-files
|
20 |
+
- name: Check docstring
|
21 |
+
run: |
|
22 |
+
pip install interrogate
|
23 |
+
interrogate -v --ignore-init-method --ignore-module --ignore-nested-functions --exclude mmseg/ops --ignore-regex "__repr__" --fail-under 80 mmseg
|
24 |
+
|
25 |
+
build:
|
26 |
+
env:
|
27 |
+
CUDA: 10.1.105-1
|
28 |
+
CUDA_SHORT: 10.1
|
29 |
+
UBUNTU_VERSION: ubuntu1804
|
30 |
+
FORCE_CUDA: 1
|
31 |
+
MMCV_CUDA_ARGS: -gencode=arch=compute_61,code=sm_61
|
32 |
+
runs-on: ubuntu-latest
|
33 |
+
strategy:
|
34 |
+
matrix:
|
35 |
+
python-version: [3.6, 3.7]
|
36 |
+
torch: [1.3.0+cpu, 1.5.0+cpu]
|
37 |
+
include:
|
38 |
+
- torch: 1.3.0+cpu
|
39 |
+
torchvision: 0.4.1+cpu
|
40 |
+
- torch: 1.5.0+cpu
|
41 |
+
torchvision: 0.6.0+cpu
|
42 |
+
- torch: 1.5.0+cpu
|
43 |
+
torchvision: 0.6.0+cpu
|
44 |
+
python-version: 3.8
|
45 |
+
- torch: 1.5.0+cu101
|
46 |
+
torchvision: 0.6.0+cu101
|
47 |
+
python-version: 3.7
|
48 |
+
- torch: 1.6.0+cu101
|
49 |
+
torchvision: 0.7.0+cu101
|
50 |
+
python-version: 3.7
|
51 |
+
|
52 |
+
steps:
|
53 |
+
- uses: actions/checkout@v2
|
54 |
+
- name: Set up Python ${{ matrix.python-version }}
|
55 |
+
uses: actions/setup-python@v2
|
56 |
+
with:
|
57 |
+
python-version: ${{ matrix.python-version }}
|
58 |
+
- name: Install CUDA
|
59 |
+
if: ${{matrix.torch == '1.5.0+cu101'}}
|
60 |
+
run: |
|
61 |
+
export INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb
|
62 |
+
wget http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER}
|
63 |
+
sudo dpkg -i ${INSTALLER}
|
64 |
+
wget https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub
|
65 |
+
sudo apt-key add 7fa2af80.pub
|
66 |
+
sudo apt update -qq
|
67 |
+
sudo apt install -y cuda-${CUDA_SHORT/./-} cuda-cufft-dev-${CUDA_SHORT/./-}
|
68 |
+
sudo apt clean
|
69 |
+
export CUDA_HOME=/usr/local/cuda-${CUDA_SHORT}
|
70 |
+
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${CUDA_HOME}/include:${LD_LIBRARY_PATH}
|
71 |
+
export PATH=${CUDA_HOME}/bin:${PATH}
|
72 |
+
sudo apt-get install -y ninja-build
|
73 |
+
- name: Install Pillow
|
74 |
+
if: ${{matrix.torchvision == '0.4.1+cpu'}}
|
75 |
+
run: pip install Pillow==6.2.2
|
76 |
+
- name: Install PyTorch
|
77 |
+
run: pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
|
78 |
+
- name: Install mmseg dependencies
|
79 |
+
run: |
|
80 |
+
pip install mmcv-full==latest+torch${{matrix.torch}} -f https://download.openmmlab.com/mmcv/dist/index.html --use-deprecated=legacy-resolver
|
81 |
+
pip install -r requirements.txt
|
82 |
+
- name: Build and install
|
83 |
+
run: rm -rf .eggs && pip install -e .
|
84 |
+
- name: Run unittests and generate coverage report
|
85 |
+
run: |
|
86 |
+
coverage run --branch --source mmseg -m pytest tests/
|
87 |
+
coverage xml
|
88 |
+
coverage report -m
|
89 |
+
# Only upload coverage report for python3.7 && pytorch1.5
|
90 |
+
- name: Upload coverage to Codecov
|
91 |
+
if: ${{matrix.torch == '1.5.0+cu101' && matrix.python-version == '3.7'}}
|
92 |
+
uses: codecov/[email protected]
|
93 |
+
with:
|
94 |
+
file: ./coverage.xml
|
95 |
+
flags: unittests
|
96 |
+
env_vars: OS,PYTHON
|
97 |
+
name: codecov-umbrella
|
98 |
+
fail_ci_if_error: false
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.github/workflows/deploy.yml
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: deploy
|
2 |
+
|
3 |
+
on: push
|
4 |
+
|
5 |
+
jobs:
|
6 |
+
build-n-publish:
|
7 |
+
runs-on: ubuntu-latest
|
8 |
+
if: startsWith(github.event.ref, 'refs/tags')
|
9 |
+
steps:
|
10 |
+
- uses: actions/checkout@v2
|
11 |
+
- name: Set up Python 3.7
|
12 |
+
uses: actions/setup-python@v2
|
13 |
+
with:
|
14 |
+
python-version: 3.7
|
15 |
+
- name: Build MMSegmentation
|
16 |
+
run: |
|
17 |
+
pip install wheel
|
18 |
+
python setup.py sdist bdist_wheel
|
19 |
+
- name: Publish distribution to PyPI
|
20 |
+
run: |
|
21 |
+
pip install twine
|
22 |
+
twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }}
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.gitignore
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
*.egg-info/
|
24 |
+
.installed.cfg
|
25 |
+
*.egg
|
26 |
+
MANIFEST
|
27 |
+
|
28 |
+
# PyInstaller
|
29 |
+
# Usually these files are written by a python script from a template
|
30 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
31 |
+
*.manifest
|
32 |
+
*.spec
|
33 |
+
|
34 |
+
# Installer logs
|
35 |
+
pip-log.txt
|
36 |
+
pip-delete-this-directory.txt
|
37 |
+
|
38 |
+
# Unit test / coverage reports
|
39 |
+
htmlcov/
|
40 |
+
.tox/
|
41 |
+
.coverage
|
42 |
+
.coverage.*
|
43 |
+
.cache
|
44 |
+
nosetests.xml
|
45 |
+
coverage.xml
|
46 |
+
*.cover
|
47 |
+
.hypothesis/
|
48 |
+
.pytest_cache/
|
49 |
+
|
50 |
+
# Translations
|
51 |
+
*.mo
|
52 |
+
*.pot
|
53 |
+
|
54 |
+
# Django stuff:
|
55 |
+
*.log
|
56 |
+
local_settings.py
|
57 |
+
db.sqlite3
|
58 |
+
|
59 |
+
# Flask stuff:
|
60 |
+
instance/
|
61 |
+
.webassets-cache
|
62 |
+
|
63 |
+
# Scrapy stuff:
|
64 |
+
.scrapy
|
65 |
+
|
66 |
+
# Sphinx documentation
|
67 |
+
docs/_build/
|
68 |
+
|
69 |
+
# PyBuilder
|
70 |
+
target/
|
71 |
+
|
72 |
+
# Jupyter Notebook
|
73 |
+
.ipynb_checkpoints
|
74 |
+
|
75 |
+
# pyenv
|
76 |
+
.python-version
|
77 |
+
|
78 |
+
# celery beat schedule file
|
79 |
+
celerybeat-schedule
|
80 |
+
|
81 |
+
# SageMath parsed files
|
82 |
+
*.sage.py
|
83 |
+
|
84 |
+
# Environments
|
85 |
+
.env
|
86 |
+
.venv
|
87 |
+
env/
|
88 |
+
venv/
|
89 |
+
ENV/
|
90 |
+
env.bak/
|
91 |
+
venv.bak/
|
92 |
+
|
93 |
+
# Spyder project settings
|
94 |
+
.spyderproject
|
95 |
+
.spyproject
|
96 |
+
|
97 |
+
# Rope project settings
|
98 |
+
.ropeproject
|
99 |
+
|
100 |
+
# mkdocs documentation
|
101 |
+
/site
|
102 |
+
|
103 |
+
# mypy
|
104 |
+
.mypy_cache/
|
105 |
+
|
106 |
+
data
|
107 |
+
.vscode
|
108 |
+
.idea
|
109 |
+
|
110 |
+
# custom
|
111 |
+
*.pkl
|
112 |
+
*.pkl.json
|
113 |
+
*.log.json
|
114 |
+
work_dirs/
|
115 |
+
|
116 |
+
# Pytorch
|
117 |
+
*.pth
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.pre-commit-config.yaml
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
repos:
|
2 |
+
- repo: https://gitlab.com/pycqa/flake8.git
|
3 |
+
rev: 3.8.3
|
4 |
+
hooks:
|
5 |
+
- id: flake8
|
6 |
+
- repo: https://github.com/asottile/seed-isort-config
|
7 |
+
rev: v2.2.0
|
8 |
+
hooks:
|
9 |
+
- id: seed-isort-config
|
10 |
+
- repo: https://github.com/timothycrosley/isort
|
11 |
+
rev: 4.3.21
|
12 |
+
hooks:
|
13 |
+
- id: isort
|
14 |
+
- repo: https://github.com/pre-commit/mirrors-yapf
|
15 |
+
rev: v0.30.0
|
16 |
+
hooks:
|
17 |
+
- id: yapf
|
18 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
19 |
+
rev: v3.1.0
|
20 |
+
hooks:
|
21 |
+
- id: trailing-whitespace
|
22 |
+
- id: check-yaml
|
23 |
+
- id: end-of-file-fixer
|
24 |
+
- id: requirements-txt-fixer
|
25 |
+
- id: double-quote-string-fixer
|
26 |
+
- id: check-merge-conflict
|
27 |
+
- id: fix-encoding-pragma
|
28 |
+
args: ["--remove"]
|
29 |
+
- id: mixed-line-ending
|
30 |
+
args: ["--fix=lf"]
|
31 |
+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
32 |
+
rev: 2.1.4
|
33 |
+
hooks:
|
34 |
+
- id: markdownlint
|
35 |
+
args: ["-r", "~MD002,~MD013,~MD029,~MD033,~MD034,~MD036"]
|
36 |
+
- repo: https://github.com/myint/docformatter
|
37 |
+
rev: v1.3.1
|
38 |
+
hooks:
|
39 |
+
- id: docformatter
|
40 |
+
args: ["--in-place", "--wrap-descriptions", "79"]
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/.readthedocs.yml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2
|
2 |
+
|
3 |
+
python:
|
4 |
+
version: 3.7
|
5 |
+
install:
|
6 |
+
- requirements: requirements/docs.txt
|
7 |
+
- requirements: requirements/readthedocs.txt
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/LICENSE
ADDED
@@ -0,0 +1,220 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Copyright 2020 The MMSegmentation Authors. All rights reserved.
|
2 |
+
|
3 |
+
Apache License
|
4 |
+
Version 2.0, January 2004
|
5 |
+
http://www.apache.org/licenses/
|
6 |
+
|
7 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
8 |
+
|
9 |
+
1. Definitions.
|
10 |
+
|
11 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
12 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
13 |
+
|
14 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
15 |
+
the copyright owner that is granting the License.
|
16 |
+
|
17 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
18 |
+
other entities that control, are controlled by, or are under common
|
19 |
+
control with that entity. For the purposes of this definition,
|
20 |
+
"control" means (i) the power, direct or indirect, to cause the
|
21 |
+
direction or management of such entity, whether by contract or
|
22 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
23 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
24 |
+
|
25 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
26 |
+
exercising permissions granted by this License.
|
27 |
+
|
28 |
+
"Source" form shall mean the preferred form for making modifications,
|
29 |
+
including but not limited to software source code, documentation
|
30 |
+
source, and configuration files.
|
31 |
+
|
32 |
+
"Object" form shall mean any form resulting from mechanical
|
33 |
+
transformation or translation of a Source form, including but
|
34 |
+
not limited to compiled object code, generated documentation,
|
35 |
+
and conversions to other media types.
|
36 |
+
|
37 |
+
"Work" shall mean the work of authorship, whether in Source or
|
38 |
+
Object form, made available under the License, as indicated by a
|
39 |
+
copyright notice that is included in or attached to the work
|
40 |
+
(an example is provided in the Appendix below).
|
41 |
+
|
42 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
43 |
+
form, that is based on (or derived from) the Work and for which the
|
44 |
+
editorial revisions, annotations, elaborations, or other modifications
|
45 |
+
represent, as a whole, an original work of authorship. For the purposes
|
46 |
+
of this License, Derivative Works shall not include works that remain
|
47 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
48 |
+
the Work and Derivative Works thereof.
|
49 |
+
|
50 |
+
"Contribution" shall mean any work of authorship, including
|
51 |
+
the original version of the Work and any modifications or additions
|
52 |
+
to that Work or Derivative Works thereof, that is intentionally
|
53 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
54 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
55 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
56 |
+
means any form of electronic, verbal, or written communication sent
|
57 |
+
to the Licensor or its representatives, including but not limited to
|
58 |
+
communication on electronic mailing lists, source code control systems,
|
59 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
60 |
+
Licensor for the purpose of discussing and improving the Work, but
|
61 |
+
excluding communication that is conspicuously marked or otherwise
|
62 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
63 |
+
|
64 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
65 |
+
on behalf of whom a Contribution has been received by Licensor and
|
66 |
+
subsequently incorporated within the Work.
|
67 |
+
|
68 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
69 |
+
this License, each Contributor hereby grants to You a perpetual,
|
70 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
71 |
+
copyright license to reproduce, prepare Derivative Works of,
|
72 |
+
publicly display, publicly perform, sublicense, and distribute the
|
73 |
+
Work and such Derivative Works in Source or Object form.
|
74 |
+
|
75 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
76 |
+
this License, each Contributor hereby grants to You a perpetual,
|
77 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
78 |
+
(except as stated in this section) patent license to make, have made,
|
79 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
80 |
+
where such license applies only to those patent claims licensable
|
81 |
+
by such Contributor that are necessarily infringed by their
|
82 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
83 |
+
with the Work to which such Contribution(s) was submitted. If You
|
84 |
+
institute patent litigation against any entity (including a
|
85 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
86 |
+
or a Contribution incorporated within the Work constitutes direct
|
87 |
+
or contributory patent infringement, then any patent licenses
|
88 |
+
granted to You under this License for that Work shall terminate
|
89 |
+
as of the date such litigation is filed.
|
90 |
+
|
91 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
92 |
+
Work or Derivative Works thereof in any medium, with or without
|
93 |
+
modifications, and in Source or Object form, provided that You
|
94 |
+
meet the following conditions:
|
95 |
+
|
96 |
+
(a) You must give any other recipients of the Work or
|
97 |
+
Derivative Works a copy of this License; and
|
98 |
+
|
99 |
+
(b) You must cause any modified files to carry prominent notices
|
100 |
+
stating that You changed the files; and
|
101 |
+
|
102 |
+
(c) You must retain, in the Source form of any Derivative Works
|
103 |
+
that You distribute, all copyright, patent, trademark, and
|
104 |
+
attribution notices from the Source form of the Work,
|
105 |
+
excluding those notices that do not pertain to any part of
|
106 |
+
the Derivative Works; and
|
107 |
+
|
108 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
109 |
+
distribution, then any Derivative Works that You distribute must
|
110 |
+
include a readable copy of the attribution notices contained
|
111 |
+
within such NOTICE file, excluding those notices that do not
|
112 |
+
pertain to any part of the Derivative Works, in at least one
|
113 |
+
of the following places: within a NOTICE text file distributed
|
114 |
+
as part of the Derivative Works; within the Source form or
|
115 |
+
documentation, if provided along with the Derivative Works; or,
|
116 |
+
within a display generated by the Derivative Works, if and
|
117 |
+
wherever such third-party notices normally appear. The contents
|
118 |
+
of the NOTICE file are for informational purposes only and
|
119 |
+
do not modify the License. You may add Your own attribution
|
120 |
+
notices within Derivative Works that You distribute, alongside
|
121 |
+
or as an addendum to the NOTICE text from the Work, provided
|
122 |
+
that such additional attribution notices cannot be construed
|
123 |
+
as modifying the License.
|
124 |
+
|
125 |
+
You may add Your own copyright statement to Your modifications and
|
126 |
+
may provide additional or different license terms and conditions
|
127 |
+
for use, reproduction, or distribution of Your modifications, or
|
128 |
+
for any such Derivative Works as a whole, provided Your use,
|
129 |
+
reproduction, and distribution of the Work otherwise complies with
|
130 |
+
the conditions stated in this License.
|
131 |
+
|
132 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
133 |
+
any Contribution intentionally submitted for inclusion in the Work
|
134 |
+
by You to the Licensor shall be under the terms and conditions of
|
135 |
+
this License, without any additional terms or conditions.
|
136 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
137 |
+
the terms of any separate license agreement you may have executed
|
138 |
+
with Licensor regarding such Contributions.
|
139 |
+
|
140 |
+
6. Trademarks. This License does not grant permission to use the trade
|
141 |
+
names, trademarks, service marks, or product names of the Licensor,
|
142 |
+
except as required for reasonable and customary use in describing the
|
143 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
144 |
+
|
145 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
146 |
+
agreed to in writing, Licensor provides the Work (and each
|
147 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
148 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
149 |
+
implied, including, without limitation, any warranties or conditions
|
150 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
151 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
152 |
+
appropriateness of using or redistributing the Work and assume any
|
153 |
+
risks associated with Your exercise of permissions under this License.
|
154 |
+
|
155 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
156 |
+
whether in tort (including negligence), contract, or otherwise,
|
157 |
+
unless required by applicable law (such as deliberate and grossly
|
158 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
159 |
+
liable to You for damages, including any direct, indirect, special,
|
160 |
+
incidental, or consequential damages of any character arising as a
|
161 |
+
result of this License or out of the use or inability to use the
|
162 |
+
Work (including but not limited to damages for loss of goodwill,
|
163 |
+
work stoppage, computer failure or malfunction, or any and all
|
164 |
+
other commercial damages or losses), even if such Contributor
|
165 |
+
has been advised of the possibility of such damages.
|
166 |
+
|
167 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
168 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
169 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
170 |
+
or other liability obligations and/or rights consistent with this
|
171 |
+
License. However, in accepting such obligations, You may act only
|
172 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
173 |
+
of any other Contributor, and only if You agree to indemnify,
|
174 |
+
defend, and hold each Contributor harmless for any liability
|
175 |
+
incurred by, or claims asserted against, such Contributor by reason
|
176 |
+
of your accepting any such warranty or additional liability.
|
177 |
+
|
178 |
+
END OF TERMS AND CONDITIONS
|
179 |
+
|
180 |
+
APPENDIX: How to apply the Apache License to your work.
|
181 |
+
|
182 |
+
To apply the Apache License to your work, attach the following
|
183 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
184 |
+
replaced with your own identifying information. (Don't include
|
185 |
+
the brackets!) The text should be enclosed in the appropriate
|
186 |
+
comment syntax for the file format. We also recommend that a
|
187 |
+
file or class name and description of purpose be included on the
|
188 |
+
same "printed page" as the copyright notice for easier
|
189 |
+
identification within third-party archives.
|
190 |
+
|
191 |
+
Copyright 2020 The MMSegmentation Authors.
|
192 |
+
|
193 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
194 |
+
you may not use this file except in compliance with the License.
|
195 |
+
You may obtain a copy of the License at
|
196 |
+
|
197 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
198 |
+
|
199 |
+
Unless required by applicable law or agreed to in writing, software
|
200 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
201 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
202 |
+
See the License for the specific language governing permissions and
|
203 |
+
limitations under the License.
|
204 |
+
|
205 |
+
|
206 |
+
======================================================================================
|
207 |
+
Swin-Transformer-Semantic-Segmentation Subcomponents:
|
208 |
+
|
209 |
+
The Swin-Transformer-Semantic-Segmentation project contains subcomponents with separate
|
210 |
+
copyright notices and license terms. Your use of the source code for the these
|
211 |
+
subcomponents is subject to the terms and conditions of the following licenses.
|
212 |
+
|
213 |
+
=======================================================================================
|
214 |
+
MIT license
|
215 |
+
=======================================================================================
|
216 |
+
|
217 |
+
The following components are provided under an MIT license.
|
218 |
+
|
219 |
+
1. swin_transformer.py - For details, mmseg/models/backbones/swin_transformer.py
|
220 |
+
Copyright (c) 2021 Microsoft
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/README.md
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Swin Transformer for Semantic Segmentaion
|
2 |
+
|
3 |
+
This repo contains the supported code and configuration files to reproduce semantic segmentaion results of [Swin Transformer](https://arxiv.org/pdf/2103.14030.pdf). It is based on [mmsegmentaion](https://github.com/open-mmlab/mmsegmentation/tree/v0.11.0).
|
4 |
+
|
5 |
+
## Updates
|
6 |
+
|
7 |
+
***05/11/2021*** Models for [MoBY](https://github.com/SwinTransformer/Transformer-SSL) are released
|
8 |
+
|
9 |
+
***04/12/2021*** Initial commits
|
10 |
+
|
11 |
+
## Results and Models
|
12 |
+
|
13 |
+
### ADE20K
|
14 |
+
|
15 |
+
| Backbone | Method | Crop Size | Lr Schd | mIoU | mIoU (ms+flip) | #params | FLOPs | config | log | model |
|
16 |
+
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
17 |
+
| Swin-T | UPerNet | 512x512 | 160K | 44.51 | 45.81 | 60M | 945G | [config](configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k.py) | [github](https://github.com/SwinTransformer/storage/releases/download/v1.0.1/upernet_swin_tiny_patch4_window7_512x512.log.json)/[baidu](https://pan.baidu.com/s/1dq0DdS17dFcmAzHlM_1rgw) | [github](https://github.com/SwinTransformer/storage/releases/download/v1.0.1/upernet_swin_tiny_patch4_window7_512x512.pth)/[baidu](https://pan.baidu.com/s/17VmmppX-PUKuek9T5H3Iqw) |
|
18 |
+
| Swin-S | UperNet | 512x512 | 160K | 47.64 | 49.47 | 81M | 1038G | [config](configs/swin/upernet_swin_small_patch4_window7_512x512_160k_ade20k.py) | [github](https://github.com/SwinTransformer/storage/releases/download/v1.0.1/upernet_swin_small_patch4_window7_512x512.log.json)/[baidu](https://pan.baidu.com/s/1ko3SVKPzH9x5B7SWCFxlig) | [github](https://github.com/SwinTransformer/storage/releases/download/v1.0.1/upernet_swin_small_patch4_window7_512x512.pth)/[baidu](https://pan.baidu.com/s/184em63etTMsf0cR_NX9zNg) |
|
19 |
+
| Swin-B | UperNet | 512x512 | 160K | 48.13 | 49.72 | 121M | 1188G | [config](configs/swin/upernet_swin_base_patch4_window7_512x512_160k_ade20k.py) | [github](https://github.com/SwinTransformer/storage/releases/download/v1.0.1/upernet_swin_base_patch4_window7_512x512.log.json)/[baidu](https://pan.baidu.com/s/1YlXXiB3GwUKhHobUajlIaQ) | [github](https://github.com/SwinTransformer/storage/releases/download/v1.0.1/upernet_swin_base_patch4_window7_512x512.pth)/[baidu](https://pan.baidu.com/s/12B2dY_niMirwtu64_9AMbg) |
|
20 |
+
|
21 |
+
**Notes**:
|
22 |
+
|
23 |
+
- **Pre-trained models can be downloaded from [Swin Transformer for ImageNet Classification](https://github.com/microsoft/Swin-Transformer)**.
|
24 |
+
- Access code for `baidu` is `swin`.
|
25 |
+
|
26 |
+
## Results of MoBY with Swin Transformer
|
27 |
+
|
28 |
+
### ADE20K
|
29 |
+
|
30 |
+
| Backbone | Method | Crop Size | Lr Schd | mIoU | mIoU (ms+flip) | #params | FLOPs | config | log | model |
|
31 |
+
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
|
32 |
+
| Swin-T | UPerNet | 512x512 | 160K | 44.06 | 45.58 | 60M | 945G | [config](configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k.py) | [github](https://github.com/SwinTransformer/storage/releases/download/v1.0.3/moby_upernet_swin_tiny_patch4_window7_512x512.log.json)/[baidu](https://pan.baidu.com/s/1i0EMiapoQ-otkDmx-_cJHg) | [github](https://github.com/SwinTransformer/storage/releases/download/v1.0.3/moby_upernet_swin_tiny_patch4_window7_512x512.pth)/[baidu](https://pan.baidu.com/s/1BYgtgkHQV89bGC7LQLS7Jw) |
|
33 |
+
|
34 |
+
**Notes**:
|
35 |
+
|
36 |
+
- The learning rate needs to be tuned for best practice.
|
37 |
+
- MoBY pre-trained models can be downloaded from [MoBY with Swin Transformer](https://github.com/SwinTransformer/Transformer-SSL).
|
38 |
+
|
39 |
+
## Usage
|
40 |
+
|
41 |
+
### Installation
|
42 |
+
|
43 |
+
Please refer to [get_started.md](https://github.com/open-mmlab/mmsegmentation/blob/master/docs/get_started.md#installation) for installation and dataset preparation.
|
44 |
+
|
45 |
+
### Inference
|
46 |
+
```
|
47 |
+
# single-gpu testing
|
48 |
+
python tools/test.py <CONFIG_FILE> <SEG_CHECKPOINT_FILE> --eval mIoU
|
49 |
+
|
50 |
+
# multi-gpu testing
|
51 |
+
tools/dist_test.sh <CONFIG_FILE> <SEG_CHECKPOINT_FILE> <GPU_NUM> --eval mIoU
|
52 |
+
|
53 |
+
# multi-gpu, multi-scale testing
|
54 |
+
tools/dist_test.sh <CONFIG_FILE> <SEG_CHECKPOINT_FILE> <GPU_NUM> --aug-test --eval mIoU
|
55 |
+
```
|
56 |
+
|
57 |
+
### Training
|
58 |
+
|
59 |
+
To train with pre-trained models, run:
|
60 |
+
```
|
61 |
+
# single-gpu training
|
62 |
+
python tools/train.py <CONFIG_FILE> --options model.pretrained=<PRETRAIN_MODEL> [model.backbone.use_checkpoint=True] [other optional arguments]
|
63 |
+
|
64 |
+
# multi-gpu training
|
65 |
+
tools/dist_train.sh <CONFIG_FILE> <GPU_NUM> --options model.pretrained=<PRETRAIN_MODEL> [model.backbone.use_checkpoint=True] [other optional arguments]
|
66 |
+
```
|
67 |
+
For example, to train an UPerNet model with a `Swin-T` backbone and 8 gpus, run:
|
68 |
+
```
|
69 |
+
tools/dist_train.sh configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k.py 8 --options model.pretrained=<PRETRAIN_MODEL>
|
70 |
+
```
|
71 |
+
|
72 |
+
**Notes:**
|
73 |
+
- `use_checkpoint` is used to save GPU memory. Please refer to [this page](https://pytorch.org/docs/stable/checkpoint.html) for more details.
|
74 |
+
- The default learning rate and training schedule is for 8 GPUs and 2 imgs/gpu.
|
75 |
+
|
76 |
+
|
77 |
+
## Citing Swin Transformer
|
78 |
+
```
|
79 |
+
@article{liu2021Swin,
|
80 |
+
title={Swin Transformer: Hierarchical Vision Transformer using Shifted Windows},
|
81 |
+
author={Liu, Ze and Lin, Yutong and Cao, Yue and Hu, Han and Wei, Yixuan and Zhang, Zheng and Lin, Stephen and Guo, Baining},
|
82 |
+
journal={arXiv preprint arXiv:2103.14030},
|
83 |
+
year={2021}
|
84 |
+
}
|
85 |
+
```
|
86 |
+
|
87 |
+
## Other Links
|
88 |
+
|
89 |
+
> **Image Classification**: See [Swin Transformer for Image Classification](https://github.com/microsoft/Swin-Transformer).
|
90 |
+
|
91 |
+
> **Object Detection**: See [Swin Transformer for Object Detection](https://github.com/SwinTransformer/Swin-Transformer-Object-Detection).
|
92 |
+
|
93 |
+
> **Self-Supervised Learning**: See [MoBY with Swin Transformer](https://github.com/SwinTransformer/Transformer-SSL).
|
94 |
+
|
95 |
+
> **Video Recognition**, See [Video Swin Transformer](https://github.com/SwinTransformer/Video-Swin-Transformer).
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/ade20k.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'ADE20KDataset'
|
3 |
+
data_root = 'data/ade/ADEChallengeData2016'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
crop_size = (512, 512)
|
7 |
+
train_pipeline = [
|
8 |
+
dict(type='LoadImageFromFile'),
|
9 |
+
dict(type='LoadAnnotations', reduce_zero_label=True),
|
10 |
+
dict(type='Resize', img_scale=(2048, 512), ratio_range=(0.5, 2.0)),
|
11 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
12 |
+
dict(type='RandomFlip', prob=0.5),
|
13 |
+
dict(type='PhotoMetricDistortion'),
|
14 |
+
dict(type='Normalize', **img_norm_cfg),
|
15 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
16 |
+
dict(type='DefaultFormatBundle'),
|
17 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
|
18 |
+
]
|
19 |
+
test_pipeline = [
|
20 |
+
dict(type='LoadImageFromFile'),
|
21 |
+
dict(
|
22 |
+
type='MultiScaleFlipAug',
|
23 |
+
img_scale=(2048, 512),
|
24 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
|
25 |
+
flip=False,
|
26 |
+
transforms=[
|
27 |
+
dict(type='Resize', keep_ratio=True),
|
28 |
+
dict(type='RandomFlip'),
|
29 |
+
dict(type='Normalize', **img_norm_cfg),
|
30 |
+
dict(type='ImageToTensor', keys=['img']),
|
31 |
+
dict(type='Collect', keys=['img']),
|
32 |
+
])
|
33 |
+
]
|
34 |
+
data = dict(
|
35 |
+
samples_per_gpu=4,
|
36 |
+
workers_per_gpu=4,
|
37 |
+
train=dict(
|
38 |
+
type=dataset_type,
|
39 |
+
data_root=data_root,
|
40 |
+
img_dir='images/training',
|
41 |
+
ann_dir='annotations/training',
|
42 |
+
pipeline=train_pipeline),
|
43 |
+
val=dict(
|
44 |
+
type=dataset_type,
|
45 |
+
data_root=data_root,
|
46 |
+
img_dir='images/validation',
|
47 |
+
ann_dir='annotations/validation',
|
48 |
+
pipeline=test_pipeline),
|
49 |
+
test=dict(
|
50 |
+
type=dataset_type,
|
51 |
+
data_root=data_root,
|
52 |
+
img_dir='images/validation',
|
53 |
+
ann_dir='annotations/validation',
|
54 |
+
pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/chase_db1.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'ChaseDB1Dataset'
|
3 |
+
data_root = 'data/CHASE_DB1'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
img_scale = (960, 999)
|
7 |
+
crop_size = (128, 128)
|
8 |
+
train_pipeline = [
|
9 |
+
dict(type='LoadImageFromFile'),
|
10 |
+
dict(type='LoadAnnotations'),
|
11 |
+
dict(type='Resize', img_scale=img_scale, ratio_range=(0.5, 2.0)),
|
12 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
13 |
+
dict(type='RandomFlip', prob=0.5),
|
14 |
+
dict(type='PhotoMetricDistortion'),
|
15 |
+
dict(type='Normalize', **img_norm_cfg),
|
16 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
17 |
+
dict(type='DefaultFormatBundle'),
|
18 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg'])
|
19 |
+
]
|
20 |
+
test_pipeline = [
|
21 |
+
dict(type='LoadImageFromFile'),
|
22 |
+
dict(
|
23 |
+
type='MultiScaleFlipAug',
|
24 |
+
img_scale=img_scale,
|
25 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0],
|
26 |
+
flip=False,
|
27 |
+
transforms=[
|
28 |
+
dict(type='Resize', keep_ratio=True),
|
29 |
+
dict(type='RandomFlip'),
|
30 |
+
dict(type='Normalize', **img_norm_cfg),
|
31 |
+
dict(type='ImageToTensor', keys=['img']),
|
32 |
+
dict(type='Collect', keys=['img'])
|
33 |
+
])
|
34 |
+
]
|
35 |
+
|
36 |
+
data = dict(
|
37 |
+
samples_per_gpu=4,
|
38 |
+
workers_per_gpu=4,
|
39 |
+
train=dict(
|
40 |
+
type='RepeatDataset',
|
41 |
+
times=40000,
|
42 |
+
dataset=dict(
|
43 |
+
type=dataset_type,
|
44 |
+
data_root=data_root,
|
45 |
+
img_dir='images/training',
|
46 |
+
ann_dir='annotations/training',
|
47 |
+
pipeline=train_pipeline)),
|
48 |
+
val=dict(
|
49 |
+
type=dataset_type,
|
50 |
+
data_root=data_root,
|
51 |
+
img_dir='images/validation',
|
52 |
+
ann_dir='annotations/validation',
|
53 |
+
pipeline=test_pipeline),
|
54 |
+
test=dict(
|
55 |
+
type=dataset_type,
|
56 |
+
data_root=data_root,
|
57 |
+
img_dir='images/validation',
|
58 |
+
ann_dir='annotations/validation',
|
59 |
+
pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/cityscapes.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'CityscapesDataset'
|
3 |
+
data_root = 'data/cityscapes/'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
crop_size = (512, 1024)
|
7 |
+
train_pipeline = [
|
8 |
+
dict(type='LoadImageFromFile'),
|
9 |
+
dict(type='LoadAnnotations'),
|
10 |
+
dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)),
|
11 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
12 |
+
dict(type='RandomFlip', prob=0.5),
|
13 |
+
dict(type='PhotoMetricDistortion'),
|
14 |
+
dict(type='Normalize', **img_norm_cfg),
|
15 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
16 |
+
dict(type='DefaultFormatBundle'),
|
17 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
|
18 |
+
]
|
19 |
+
test_pipeline = [
|
20 |
+
dict(type='LoadImageFromFile'),
|
21 |
+
dict(
|
22 |
+
type='MultiScaleFlipAug',
|
23 |
+
img_scale=(2048, 1024),
|
24 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
|
25 |
+
flip=False,
|
26 |
+
transforms=[
|
27 |
+
dict(type='Resize', keep_ratio=True),
|
28 |
+
dict(type='RandomFlip'),
|
29 |
+
dict(type='Normalize', **img_norm_cfg),
|
30 |
+
dict(type='ImageToTensor', keys=['img']),
|
31 |
+
dict(type='Collect', keys=['img']),
|
32 |
+
])
|
33 |
+
]
|
34 |
+
data = dict(
|
35 |
+
samples_per_gpu=2,
|
36 |
+
workers_per_gpu=2,
|
37 |
+
train=dict(
|
38 |
+
type=dataset_type,
|
39 |
+
data_root=data_root,
|
40 |
+
img_dir='leftImg8bit/train',
|
41 |
+
ann_dir='gtFine/train',
|
42 |
+
pipeline=train_pipeline),
|
43 |
+
val=dict(
|
44 |
+
type=dataset_type,
|
45 |
+
data_root=data_root,
|
46 |
+
img_dir='leftImg8bit/val',
|
47 |
+
ann_dir='gtFine/val',
|
48 |
+
pipeline=test_pipeline),
|
49 |
+
test=dict(
|
50 |
+
type=dataset_type,
|
51 |
+
data_root=data_root,
|
52 |
+
img_dir='leftImg8bit/val',
|
53 |
+
ann_dir='gtFine/val',
|
54 |
+
pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/cityscapes_769x769.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_base_ = './cityscapes.py'
|
2 |
+
img_norm_cfg = dict(
|
3 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
4 |
+
crop_size = (769, 769)
|
5 |
+
train_pipeline = [
|
6 |
+
dict(type='LoadImageFromFile'),
|
7 |
+
dict(type='LoadAnnotations'),
|
8 |
+
dict(type='Resize', img_scale=(2049, 1025), ratio_range=(0.5, 2.0)),
|
9 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
10 |
+
dict(type='RandomFlip', prob=0.5),
|
11 |
+
dict(type='PhotoMetricDistortion'),
|
12 |
+
dict(type='Normalize', **img_norm_cfg),
|
13 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
14 |
+
dict(type='DefaultFormatBundle'),
|
15 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
|
16 |
+
]
|
17 |
+
test_pipeline = [
|
18 |
+
dict(type='LoadImageFromFile'),
|
19 |
+
dict(
|
20 |
+
type='MultiScaleFlipAug',
|
21 |
+
img_scale=(2049, 1025),
|
22 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
|
23 |
+
flip=False,
|
24 |
+
transforms=[
|
25 |
+
dict(type='Resize', keep_ratio=True),
|
26 |
+
dict(type='RandomFlip'),
|
27 |
+
dict(type='Normalize', **img_norm_cfg),
|
28 |
+
dict(type='ImageToTensor', keys=['img']),
|
29 |
+
dict(type='Collect', keys=['img']),
|
30 |
+
])
|
31 |
+
]
|
32 |
+
data = dict(
|
33 |
+
train=dict(pipeline=train_pipeline),
|
34 |
+
val=dict(pipeline=test_pipeline),
|
35 |
+
test=dict(pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/drive.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'DRIVEDataset'
|
3 |
+
data_root = 'data/DRIVE'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
img_scale = (584, 565)
|
7 |
+
crop_size = (64, 64)
|
8 |
+
train_pipeline = [
|
9 |
+
dict(type='LoadImageFromFile'),
|
10 |
+
dict(type='LoadAnnotations'),
|
11 |
+
dict(type='Resize', img_scale=img_scale, ratio_range=(0.5, 2.0)),
|
12 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
13 |
+
dict(type='RandomFlip', prob=0.5),
|
14 |
+
dict(type='PhotoMetricDistortion'),
|
15 |
+
dict(type='Normalize', **img_norm_cfg),
|
16 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
17 |
+
dict(type='DefaultFormatBundle'),
|
18 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg'])
|
19 |
+
]
|
20 |
+
test_pipeline = [
|
21 |
+
dict(type='LoadImageFromFile'),
|
22 |
+
dict(
|
23 |
+
type='MultiScaleFlipAug',
|
24 |
+
img_scale=img_scale,
|
25 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0],
|
26 |
+
flip=False,
|
27 |
+
transforms=[
|
28 |
+
dict(type='Resize', keep_ratio=True),
|
29 |
+
dict(type='RandomFlip'),
|
30 |
+
dict(type='Normalize', **img_norm_cfg),
|
31 |
+
dict(type='ImageToTensor', keys=['img']),
|
32 |
+
dict(type='Collect', keys=['img'])
|
33 |
+
])
|
34 |
+
]
|
35 |
+
|
36 |
+
data = dict(
|
37 |
+
samples_per_gpu=4,
|
38 |
+
workers_per_gpu=4,
|
39 |
+
train=dict(
|
40 |
+
type='RepeatDataset',
|
41 |
+
times=40000,
|
42 |
+
dataset=dict(
|
43 |
+
type=dataset_type,
|
44 |
+
data_root=data_root,
|
45 |
+
img_dir='images/training',
|
46 |
+
ann_dir='annotations/training',
|
47 |
+
pipeline=train_pipeline)),
|
48 |
+
val=dict(
|
49 |
+
type=dataset_type,
|
50 |
+
data_root=data_root,
|
51 |
+
img_dir='images/validation',
|
52 |
+
ann_dir='annotations/validation',
|
53 |
+
pipeline=test_pipeline),
|
54 |
+
test=dict(
|
55 |
+
type=dataset_type,
|
56 |
+
data_root=data_root,
|
57 |
+
img_dir='images/validation',
|
58 |
+
ann_dir='annotations/validation',
|
59 |
+
pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/hrf.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'HRFDataset'
|
3 |
+
data_root = 'data/HRF'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
img_scale = (2336, 3504)
|
7 |
+
crop_size = (256, 256)
|
8 |
+
train_pipeline = [
|
9 |
+
dict(type='LoadImageFromFile'),
|
10 |
+
dict(type='LoadAnnotations'),
|
11 |
+
dict(type='Resize', img_scale=img_scale, ratio_range=(0.5, 2.0)),
|
12 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
13 |
+
dict(type='RandomFlip', prob=0.5),
|
14 |
+
dict(type='PhotoMetricDistortion'),
|
15 |
+
dict(type='Normalize', **img_norm_cfg),
|
16 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
17 |
+
dict(type='DefaultFormatBundle'),
|
18 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg'])
|
19 |
+
]
|
20 |
+
test_pipeline = [
|
21 |
+
dict(type='LoadImageFromFile'),
|
22 |
+
dict(
|
23 |
+
type='MultiScaleFlipAug',
|
24 |
+
img_scale=img_scale,
|
25 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0],
|
26 |
+
flip=False,
|
27 |
+
transforms=[
|
28 |
+
dict(type='Resize', keep_ratio=True),
|
29 |
+
dict(type='RandomFlip'),
|
30 |
+
dict(type='Normalize', **img_norm_cfg),
|
31 |
+
dict(type='ImageToTensor', keys=['img']),
|
32 |
+
dict(type='Collect', keys=['img'])
|
33 |
+
])
|
34 |
+
]
|
35 |
+
|
36 |
+
data = dict(
|
37 |
+
samples_per_gpu=4,
|
38 |
+
workers_per_gpu=4,
|
39 |
+
train=dict(
|
40 |
+
type='RepeatDataset',
|
41 |
+
times=40000,
|
42 |
+
dataset=dict(
|
43 |
+
type=dataset_type,
|
44 |
+
data_root=data_root,
|
45 |
+
img_dir='images/training',
|
46 |
+
ann_dir='annotations/training',
|
47 |
+
pipeline=train_pipeline)),
|
48 |
+
val=dict(
|
49 |
+
type=dataset_type,
|
50 |
+
data_root=data_root,
|
51 |
+
img_dir='images/validation',
|
52 |
+
ann_dir='annotations/validation',
|
53 |
+
pipeline=test_pipeline),
|
54 |
+
test=dict(
|
55 |
+
type=dataset_type,
|
56 |
+
data_root=data_root,
|
57 |
+
img_dir='images/validation',
|
58 |
+
ann_dir='annotations/validation',
|
59 |
+
pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/pascal_context.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'PascalContextDataset'
|
3 |
+
data_root = 'data/VOCdevkit/VOC2010/'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
|
7 |
+
img_scale = (520, 520)
|
8 |
+
crop_size = (480, 480)
|
9 |
+
|
10 |
+
train_pipeline = [
|
11 |
+
dict(type='LoadImageFromFile'),
|
12 |
+
dict(type='LoadAnnotations'),
|
13 |
+
dict(type='Resize', img_scale=img_scale, ratio_range=(0.5, 2.0)),
|
14 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
15 |
+
dict(type='RandomFlip', prob=0.5),
|
16 |
+
dict(type='PhotoMetricDistortion'),
|
17 |
+
dict(type='Normalize', **img_norm_cfg),
|
18 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
19 |
+
dict(type='DefaultFormatBundle'),
|
20 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
|
21 |
+
]
|
22 |
+
test_pipeline = [
|
23 |
+
dict(type='LoadImageFromFile'),
|
24 |
+
dict(
|
25 |
+
type='MultiScaleFlipAug',
|
26 |
+
img_scale=img_scale,
|
27 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
|
28 |
+
flip=False,
|
29 |
+
transforms=[
|
30 |
+
dict(type='Resize', keep_ratio=True),
|
31 |
+
dict(type='RandomFlip'),
|
32 |
+
dict(type='Normalize', **img_norm_cfg),
|
33 |
+
dict(type='ImageToTensor', keys=['img']),
|
34 |
+
dict(type='Collect', keys=['img']),
|
35 |
+
])
|
36 |
+
]
|
37 |
+
data = dict(
|
38 |
+
samples_per_gpu=4,
|
39 |
+
workers_per_gpu=4,
|
40 |
+
train=dict(
|
41 |
+
type=dataset_type,
|
42 |
+
data_root=data_root,
|
43 |
+
img_dir='JPEGImages',
|
44 |
+
ann_dir='SegmentationClassContext',
|
45 |
+
split='ImageSets/SegmentationContext/train.txt',
|
46 |
+
pipeline=train_pipeline),
|
47 |
+
val=dict(
|
48 |
+
type=dataset_type,
|
49 |
+
data_root=data_root,
|
50 |
+
img_dir='JPEGImages',
|
51 |
+
ann_dir='SegmentationClassContext',
|
52 |
+
split='ImageSets/SegmentationContext/val.txt',
|
53 |
+
pipeline=test_pipeline),
|
54 |
+
test=dict(
|
55 |
+
type=dataset_type,
|
56 |
+
data_root=data_root,
|
57 |
+
img_dir='JPEGImages',
|
58 |
+
ann_dir='SegmentationClassContext',
|
59 |
+
split='ImageSets/SegmentationContext/val.txt',
|
60 |
+
pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/pascal_voc12.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'PascalVOCDataset'
|
3 |
+
data_root = 'data/VOCdevkit/VOC2012'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
crop_size = (512, 512)
|
7 |
+
train_pipeline = [
|
8 |
+
dict(type='LoadImageFromFile'),
|
9 |
+
dict(type='LoadAnnotations'),
|
10 |
+
dict(type='Resize', img_scale=(2048, 512), ratio_range=(0.5, 2.0)),
|
11 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
12 |
+
dict(type='RandomFlip', prob=0.5),
|
13 |
+
dict(type='PhotoMetricDistortion'),
|
14 |
+
dict(type='Normalize', **img_norm_cfg),
|
15 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
16 |
+
dict(type='DefaultFormatBundle'),
|
17 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
|
18 |
+
]
|
19 |
+
test_pipeline = [
|
20 |
+
dict(type='LoadImageFromFile'),
|
21 |
+
dict(
|
22 |
+
type='MultiScaleFlipAug',
|
23 |
+
img_scale=(2048, 512),
|
24 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
|
25 |
+
flip=False,
|
26 |
+
transforms=[
|
27 |
+
dict(type='Resize', keep_ratio=True),
|
28 |
+
dict(type='RandomFlip'),
|
29 |
+
dict(type='Normalize', **img_norm_cfg),
|
30 |
+
dict(type='ImageToTensor', keys=['img']),
|
31 |
+
dict(type='Collect', keys=['img']),
|
32 |
+
])
|
33 |
+
]
|
34 |
+
data = dict(
|
35 |
+
samples_per_gpu=4,
|
36 |
+
workers_per_gpu=4,
|
37 |
+
train=dict(
|
38 |
+
type=dataset_type,
|
39 |
+
data_root=data_root,
|
40 |
+
img_dir='JPEGImages',
|
41 |
+
ann_dir='SegmentationClass',
|
42 |
+
split='ImageSets/Segmentation/train.txt',
|
43 |
+
pipeline=train_pipeline),
|
44 |
+
val=dict(
|
45 |
+
type=dataset_type,
|
46 |
+
data_root=data_root,
|
47 |
+
img_dir='JPEGImages',
|
48 |
+
ann_dir='SegmentationClass',
|
49 |
+
split='ImageSets/Segmentation/val.txt',
|
50 |
+
pipeline=test_pipeline),
|
51 |
+
test=dict(
|
52 |
+
type=dataset_type,
|
53 |
+
data_root=data_root,
|
54 |
+
img_dir='JPEGImages',
|
55 |
+
ann_dir='SegmentationClass',
|
56 |
+
split='ImageSets/Segmentation/val.txt',
|
57 |
+
pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/pascal_voc12_aug.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
_base_ = './pascal_voc12.py'
|
2 |
+
# dataset settings
|
3 |
+
data = dict(
|
4 |
+
train=dict(
|
5 |
+
ann_dir=['SegmentationClass', 'SegmentationClassAug'],
|
6 |
+
split=[
|
7 |
+
'ImageSets/Segmentation/train.txt',
|
8 |
+
'ImageSets/Segmentation/aug.txt'
|
9 |
+
]))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/datasets/stare.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# dataset settings
|
2 |
+
dataset_type = 'STAREDataset'
|
3 |
+
data_root = 'data/STARE'
|
4 |
+
img_norm_cfg = dict(
|
5 |
+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
6 |
+
img_scale = (605, 700)
|
7 |
+
crop_size = (128, 128)
|
8 |
+
train_pipeline = [
|
9 |
+
dict(type='LoadImageFromFile'),
|
10 |
+
dict(type='LoadAnnotations'),
|
11 |
+
dict(type='Resize', img_scale=img_scale, ratio_range=(0.5, 2.0)),
|
12 |
+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
13 |
+
dict(type='RandomFlip', prob=0.5),
|
14 |
+
dict(type='PhotoMetricDistortion'),
|
15 |
+
dict(type='Normalize', **img_norm_cfg),
|
16 |
+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
17 |
+
dict(type='DefaultFormatBundle'),
|
18 |
+
dict(type='Collect', keys=['img', 'gt_semantic_seg'])
|
19 |
+
]
|
20 |
+
test_pipeline = [
|
21 |
+
dict(type='LoadImageFromFile'),
|
22 |
+
dict(
|
23 |
+
type='MultiScaleFlipAug',
|
24 |
+
img_scale=img_scale,
|
25 |
+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0],
|
26 |
+
flip=False,
|
27 |
+
transforms=[
|
28 |
+
dict(type='Resize', keep_ratio=True),
|
29 |
+
dict(type='RandomFlip'),
|
30 |
+
dict(type='Normalize', **img_norm_cfg),
|
31 |
+
dict(type='ImageToTensor', keys=['img']),
|
32 |
+
dict(type='Collect', keys=['img'])
|
33 |
+
])
|
34 |
+
]
|
35 |
+
|
36 |
+
data = dict(
|
37 |
+
samples_per_gpu=4,
|
38 |
+
workers_per_gpu=4,
|
39 |
+
train=dict(
|
40 |
+
type='RepeatDataset',
|
41 |
+
times=40000,
|
42 |
+
dataset=dict(
|
43 |
+
type=dataset_type,
|
44 |
+
data_root=data_root,
|
45 |
+
img_dir='images/training',
|
46 |
+
ann_dir='annotations/training',
|
47 |
+
pipeline=train_pipeline)),
|
48 |
+
val=dict(
|
49 |
+
type=dataset_type,
|
50 |
+
data_root=data_root,
|
51 |
+
img_dir='images/validation',
|
52 |
+
ann_dir='annotations/validation',
|
53 |
+
pipeline=test_pipeline),
|
54 |
+
test=dict(
|
55 |
+
type=dataset_type,
|
56 |
+
data_root=data_root,
|
57 |
+
img_dir='images/validation',
|
58 |
+
ann_dir='annotations/validation',
|
59 |
+
pipeline=test_pipeline))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/default_runtime.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# yapf:disable
|
2 |
+
log_config = dict(
|
3 |
+
interval=50,
|
4 |
+
hooks=[
|
5 |
+
dict(type='TextLoggerHook', by_epoch=False),
|
6 |
+
# dict(type='TensorboardLoggerHook')
|
7 |
+
])
|
8 |
+
# yapf:enable
|
9 |
+
dist_params = dict(backend='nccl')
|
10 |
+
log_level = 'INFO'
|
11 |
+
load_from = None
|
12 |
+
resume_from = None
|
13 |
+
workflow = [('train', 1)]
|
14 |
+
cudnn_benchmark = True
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/ann_r50-d8.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='ANNHead',
|
19 |
+
in_channels=[1024, 2048],
|
20 |
+
in_index=[2, 3],
|
21 |
+
channels=512,
|
22 |
+
project_channels=256,
|
23 |
+
query_scales=(1, ),
|
24 |
+
key_pool_scales=(1, 3, 6, 8),
|
25 |
+
dropout_ratio=0.1,
|
26 |
+
num_classes=19,
|
27 |
+
norm_cfg=norm_cfg,
|
28 |
+
align_corners=False,
|
29 |
+
loss_decode=dict(
|
30 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
31 |
+
auxiliary_head=dict(
|
32 |
+
type='FCNHead',
|
33 |
+
in_channels=1024,
|
34 |
+
in_index=2,
|
35 |
+
channels=256,
|
36 |
+
num_convs=1,
|
37 |
+
concat_input=False,
|
38 |
+
dropout_ratio=0.1,
|
39 |
+
num_classes=19,
|
40 |
+
norm_cfg=norm_cfg,
|
41 |
+
align_corners=False,
|
42 |
+
loss_decode=dict(
|
43 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
44 |
+
# model training and testing settings
|
45 |
+
train_cfg=dict(),
|
46 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/apcnet_r50-d8.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='APCHead',
|
19 |
+
in_channels=2048,
|
20 |
+
in_index=3,
|
21 |
+
channels=512,
|
22 |
+
pool_scales=(1, 2, 3, 6),
|
23 |
+
dropout_ratio=0.1,
|
24 |
+
num_classes=19,
|
25 |
+
norm_cfg=dict(type='SyncBN', requires_grad=True),
|
26 |
+
align_corners=False,
|
27 |
+
loss_decode=dict(
|
28 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
29 |
+
auxiliary_head=dict(
|
30 |
+
type='FCNHead',
|
31 |
+
in_channels=1024,
|
32 |
+
in_index=2,
|
33 |
+
channels=256,
|
34 |
+
num_convs=1,
|
35 |
+
concat_input=False,
|
36 |
+
dropout_ratio=0.1,
|
37 |
+
num_classes=19,
|
38 |
+
norm_cfg=norm_cfg,
|
39 |
+
align_corners=False,
|
40 |
+
loss_decode=dict(
|
41 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
42 |
+
# model training and testing settings
|
43 |
+
train_cfg=dict(),
|
44 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/ccnet_r50-d8.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='CCHead',
|
19 |
+
in_channels=2048,
|
20 |
+
in_index=3,
|
21 |
+
channels=512,
|
22 |
+
recurrence=2,
|
23 |
+
dropout_ratio=0.1,
|
24 |
+
num_classes=19,
|
25 |
+
norm_cfg=norm_cfg,
|
26 |
+
align_corners=False,
|
27 |
+
loss_decode=dict(
|
28 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
29 |
+
auxiliary_head=dict(
|
30 |
+
type='FCNHead',
|
31 |
+
in_channels=1024,
|
32 |
+
in_index=2,
|
33 |
+
channels=256,
|
34 |
+
num_convs=1,
|
35 |
+
concat_input=False,
|
36 |
+
dropout_ratio=0.1,
|
37 |
+
num_classes=19,
|
38 |
+
norm_cfg=norm_cfg,
|
39 |
+
align_corners=False,
|
40 |
+
loss_decode=dict(
|
41 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
42 |
+
# model training and testing settings
|
43 |
+
train_cfg=dict(),
|
44 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/cgnet.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', eps=1e-03, requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
backbone=dict(
|
6 |
+
type='CGNet',
|
7 |
+
norm_cfg=norm_cfg,
|
8 |
+
in_channels=3,
|
9 |
+
num_channels=(32, 64, 128),
|
10 |
+
num_blocks=(3, 21),
|
11 |
+
dilations=(2, 4),
|
12 |
+
reductions=(8, 16)),
|
13 |
+
decode_head=dict(
|
14 |
+
type='FCNHead',
|
15 |
+
in_channels=256,
|
16 |
+
in_index=2,
|
17 |
+
channels=256,
|
18 |
+
num_convs=0,
|
19 |
+
concat_input=False,
|
20 |
+
dropout_ratio=0,
|
21 |
+
num_classes=19,
|
22 |
+
norm_cfg=norm_cfg,
|
23 |
+
loss_decode=dict(
|
24 |
+
type='CrossEntropyLoss',
|
25 |
+
use_sigmoid=False,
|
26 |
+
loss_weight=1.0,
|
27 |
+
class_weight=[
|
28 |
+
2.5959933, 6.7415504, 3.5354059, 9.8663225, 9.690899, 9.369352,
|
29 |
+
10.289121, 9.953208, 4.3097677, 9.490387, 7.674431, 9.396905,
|
30 |
+
10.347791, 6.3927646, 10.226669, 10.241062, 10.280587,
|
31 |
+
10.396974, 10.055647
|
32 |
+
])),
|
33 |
+
# model training and testing settings
|
34 |
+
train_cfg=dict(sampler=None),
|
35 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/danet_r50-d8.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='DAHead',
|
19 |
+
in_channels=2048,
|
20 |
+
in_index=3,
|
21 |
+
channels=512,
|
22 |
+
pam_channels=64,
|
23 |
+
dropout_ratio=0.1,
|
24 |
+
num_classes=19,
|
25 |
+
norm_cfg=norm_cfg,
|
26 |
+
align_corners=False,
|
27 |
+
loss_decode=dict(
|
28 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
29 |
+
auxiliary_head=dict(
|
30 |
+
type='FCNHead',
|
31 |
+
in_channels=1024,
|
32 |
+
in_index=2,
|
33 |
+
channels=256,
|
34 |
+
num_convs=1,
|
35 |
+
concat_input=False,
|
36 |
+
dropout_ratio=0.1,
|
37 |
+
num_classes=19,
|
38 |
+
norm_cfg=norm_cfg,
|
39 |
+
align_corners=False,
|
40 |
+
loss_decode=dict(
|
41 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
42 |
+
# model training and testing settings
|
43 |
+
train_cfg=dict(),
|
44 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/deeplabv3_r50-d8.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='ASPPHead',
|
19 |
+
in_channels=2048,
|
20 |
+
in_index=3,
|
21 |
+
channels=512,
|
22 |
+
dilations=(1, 12, 24, 36),
|
23 |
+
dropout_ratio=0.1,
|
24 |
+
num_classes=19,
|
25 |
+
norm_cfg=norm_cfg,
|
26 |
+
align_corners=False,
|
27 |
+
loss_decode=dict(
|
28 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
29 |
+
auxiliary_head=dict(
|
30 |
+
type='FCNHead',
|
31 |
+
in_channels=1024,
|
32 |
+
in_index=2,
|
33 |
+
channels=256,
|
34 |
+
num_convs=1,
|
35 |
+
concat_input=False,
|
36 |
+
dropout_ratio=0.1,
|
37 |
+
num_classes=19,
|
38 |
+
norm_cfg=norm_cfg,
|
39 |
+
align_corners=False,
|
40 |
+
loss_decode=dict(
|
41 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
42 |
+
# model training and testing settings
|
43 |
+
train_cfg=dict(),
|
44 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/deeplabv3_unet_s5-d16.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained=None,
|
6 |
+
backbone=dict(
|
7 |
+
type='UNet',
|
8 |
+
in_channels=3,
|
9 |
+
base_channels=64,
|
10 |
+
num_stages=5,
|
11 |
+
strides=(1, 1, 1, 1, 1),
|
12 |
+
enc_num_convs=(2, 2, 2, 2, 2),
|
13 |
+
dec_num_convs=(2, 2, 2, 2),
|
14 |
+
downsamples=(True, True, True, True),
|
15 |
+
enc_dilations=(1, 1, 1, 1, 1),
|
16 |
+
dec_dilations=(1, 1, 1, 1),
|
17 |
+
with_cp=False,
|
18 |
+
conv_cfg=None,
|
19 |
+
norm_cfg=norm_cfg,
|
20 |
+
act_cfg=dict(type='ReLU'),
|
21 |
+
upsample_cfg=dict(type='InterpConv'),
|
22 |
+
norm_eval=False),
|
23 |
+
decode_head=dict(
|
24 |
+
type='ASPPHead',
|
25 |
+
in_channels=64,
|
26 |
+
in_index=4,
|
27 |
+
channels=16,
|
28 |
+
dilations=(1, 12, 24, 36),
|
29 |
+
dropout_ratio=0.1,
|
30 |
+
num_classes=2,
|
31 |
+
norm_cfg=norm_cfg,
|
32 |
+
align_corners=False,
|
33 |
+
loss_decode=dict(
|
34 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
35 |
+
auxiliary_head=dict(
|
36 |
+
type='FCNHead',
|
37 |
+
in_channels=128,
|
38 |
+
in_index=3,
|
39 |
+
channels=64,
|
40 |
+
num_convs=1,
|
41 |
+
concat_input=False,
|
42 |
+
dropout_ratio=0.1,
|
43 |
+
num_classes=2,
|
44 |
+
norm_cfg=norm_cfg,
|
45 |
+
align_corners=False,
|
46 |
+
loss_decode=dict(
|
47 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
48 |
+
# model training and testing settings
|
49 |
+
train_cfg=dict(),
|
50 |
+
test_cfg=dict(mode='slide', crop_size=256, stride=170))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/deeplabv3plus_r50-d8.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='DepthwiseSeparableASPPHead',
|
19 |
+
in_channels=2048,
|
20 |
+
in_index=3,
|
21 |
+
channels=512,
|
22 |
+
dilations=(1, 12, 24, 36),
|
23 |
+
c1_in_channels=256,
|
24 |
+
c1_channels=48,
|
25 |
+
dropout_ratio=0.1,
|
26 |
+
num_classes=19,
|
27 |
+
norm_cfg=norm_cfg,
|
28 |
+
align_corners=False,
|
29 |
+
loss_decode=dict(
|
30 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
31 |
+
auxiliary_head=dict(
|
32 |
+
type='FCNHead',
|
33 |
+
in_channels=1024,
|
34 |
+
in_index=2,
|
35 |
+
channels=256,
|
36 |
+
num_convs=1,
|
37 |
+
concat_input=False,
|
38 |
+
dropout_ratio=0.1,
|
39 |
+
num_classes=19,
|
40 |
+
norm_cfg=norm_cfg,
|
41 |
+
align_corners=False,
|
42 |
+
loss_decode=dict(
|
43 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
44 |
+
# model training and testing settings
|
45 |
+
train_cfg=dict(),
|
46 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/dmnet_r50-d8.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='DMHead',
|
19 |
+
in_channels=2048,
|
20 |
+
in_index=3,
|
21 |
+
channels=512,
|
22 |
+
filter_sizes=(1, 3, 5, 7),
|
23 |
+
dropout_ratio=0.1,
|
24 |
+
num_classes=19,
|
25 |
+
norm_cfg=dict(type='SyncBN', requires_grad=True),
|
26 |
+
align_corners=False,
|
27 |
+
loss_decode=dict(
|
28 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
29 |
+
auxiliary_head=dict(
|
30 |
+
type='FCNHead',
|
31 |
+
in_channels=1024,
|
32 |
+
in_index=2,
|
33 |
+
channels=256,
|
34 |
+
num_convs=1,
|
35 |
+
concat_input=False,
|
36 |
+
dropout_ratio=0.1,
|
37 |
+
num_classes=19,
|
38 |
+
norm_cfg=norm_cfg,
|
39 |
+
align_corners=False,
|
40 |
+
loss_decode=dict(
|
41 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
42 |
+
# model training and testing settings
|
43 |
+
train_cfg=dict(),
|
44 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/dnl_r50-d8.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='DNLHead',
|
19 |
+
in_channels=2048,
|
20 |
+
in_index=3,
|
21 |
+
channels=512,
|
22 |
+
dropout_ratio=0.1,
|
23 |
+
reduction=2,
|
24 |
+
use_scale=True,
|
25 |
+
mode='embedded_gaussian',
|
26 |
+
num_classes=19,
|
27 |
+
norm_cfg=norm_cfg,
|
28 |
+
align_corners=False,
|
29 |
+
loss_decode=dict(
|
30 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
31 |
+
auxiliary_head=dict(
|
32 |
+
type='FCNHead',
|
33 |
+
in_channels=1024,
|
34 |
+
in_index=2,
|
35 |
+
channels=256,
|
36 |
+
num_convs=1,
|
37 |
+
concat_input=False,
|
38 |
+
dropout_ratio=0.1,
|
39 |
+
num_classes=19,
|
40 |
+
norm_cfg=norm_cfg,
|
41 |
+
align_corners=False,
|
42 |
+
loss_decode=dict(
|
43 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
44 |
+
# model training and testing settings
|
45 |
+
train_cfg=dict(),
|
46 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/emanet_r50-d8.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='EMAHead',
|
19 |
+
in_channels=2048,
|
20 |
+
in_index=3,
|
21 |
+
channels=256,
|
22 |
+
ema_channels=512,
|
23 |
+
num_bases=64,
|
24 |
+
num_stages=3,
|
25 |
+
momentum=0.1,
|
26 |
+
dropout_ratio=0.1,
|
27 |
+
num_classes=19,
|
28 |
+
norm_cfg=norm_cfg,
|
29 |
+
align_corners=False,
|
30 |
+
loss_decode=dict(
|
31 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
|
32 |
+
auxiliary_head=dict(
|
33 |
+
type='FCNHead',
|
34 |
+
in_channels=1024,
|
35 |
+
in_index=2,
|
36 |
+
channels=256,
|
37 |
+
num_convs=1,
|
38 |
+
concat_input=False,
|
39 |
+
dropout_ratio=0.1,
|
40 |
+
num_classes=19,
|
41 |
+
norm_cfg=norm_cfg,
|
42 |
+
align_corners=False,
|
43 |
+
loss_decode=dict(
|
44 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
45 |
+
# model training and testing settings
|
46 |
+
train_cfg=dict(),
|
47 |
+
test_cfg=dict(mode='whole'))
|
FoodSeg103/Swin-Transformer-Semantic-Segmentation-main/configs/_base_/models/encnet_r50-d8.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# model settings
|
2 |
+
norm_cfg = dict(type='SyncBN', requires_grad=True)
|
3 |
+
model = dict(
|
4 |
+
type='EncoderDecoder',
|
5 |
+
pretrained='open-mmlab://resnet50_v1c',
|
6 |
+
backbone=dict(
|
7 |
+
type='ResNetV1c',
|
8 |
+
depth=50,
|
9 |
+
num_stages=4,
|
10 |
+
out_indices=(0, 1, 2, 3),
|
11 |
+
dilations=(1, 1, 2, 4),
|
12 |
+
strides=(1, 2, 1, 1),
|
13 |
+
norm_cfg=norm_cfg,
|
14 |
+
norm_eval=False,
|
15 |
+
style='pytorch',
|
16 |
+
contract_dilation=True),
|
17 |
+
decode_head=dict(
|
18 |
+
type='EncHead',
|
19 |
+
in_channels=[512, 1024, 2048],
|
20 |
+
in_index=(1, 2, 3),
|
21 |
+
channels=512,
|
22 |
+
num_codes=32,
|
23 |
+
use_se_loss=True,
|
24 |
+
add_lateral=False,
|
25 |
+
dropout_ratio=0.1,
|
26 |
+
num_classes=19,
|
27 |
+
norm_cfg=norm_cfg,
|
28 |
+
align_corners=False,
|
29 |
+
loss_decode=dict(
|
30 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0),
|
31 |
+
loss_se_decode=dict(
|
32 |
+
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.2)),
|
33 |
+
auxiliary_head=dict(
|
34 |
+
type='FCNHead',
|
35 |
+
in_channels=1024,
|
36 |
+
in_index=2,
|
37 |
+
channels=256,
|
38 |
+
num_convs=1,
|
39 |
+
concat_input=False,
|
40 |
+
dropout_ratio=0.1,
|
41 |
+
num_classes=19,
|
42 |
+
norm_cfg=norm_cfg,
|
43 |
+
align_corners=False,
|
44 |
+
loss_decode=dict(
|
45 |
+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
|
46 |
+
# model training and testing settings
|
47 |
+
train_cfg=dict(),
|
48 |
+
test_cfg=dict(mode='whole'))
|