Skip to content

Commit e074c62

Browse files
author
changqingai
committed
v2.0
1 parent f70bfd1 commit e074c62

File tree

1,965 files changed

+79079
-228307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,965 files changed

+79079
-228307
lines changed

.gitattributes

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
opencv_world342.dll filter=lfs diff=lfs merge=lfs -text
2-
opencv_world342d.dll filter=lfs diff=lfs merge=lfs -text
1+
*.dll filter=lfs diff=lfs merge=lfs -text
32
libprotobufd.lib filter=lfs diff=lfs merge=lfs -text

LICENSE.txt

+2,638-2,540
Large diffs are not rendered by default.

Modules/RefineDet/detect.py

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tencent is pleased to support the open source community by making GameAISDK available.
4+
5+
This source code file is licensed under the GNU General Public License Version 3.
6+
For full details, please refer to the file "LICENSE.txt" which is provided as part of this source code package.
7+
8+
Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
9+
"""
10+
11+
import os
12+
import sys
13+
import platform
14+
__is_windows_system = platform.platform().lower().startswith('window')
15+
__is_linux_system = platform.platform().lower().startswith('linux')
16+
if __is_windows_system:
17+
sys.path.append(os.path.dirname(__file__))
18+
sys.path.append(os.path.join(os.path.dirname(__file__), 'windows'))
19+
from windows.detect_util import main
20+
elif __is_linux_system:
21+
sys.path.append(os.path.dirname(__file__))
22+
sys.path.append(os.path.join(os.path.dirname(__file__), 'ubuntu'))
23+
from ubuntu.detect_util import main
24+
else:
25+
raise Exception('system is not support!')
26+
27+
"""
28+
parser = argparse.ArgumentParser(description='RefineDet Training')
29+
## basic configurations
30+
parser.add_argument('-v', '--version', default='Refine_hc2net_version3',
31+
help='Refine_vgg, Refine_mobile, Refine_hcnet, Refine_hc2net, Refine_hc2net_version2, Refine_hc2net_version3, '
32+
'Refine_hc2net_version4, Refine_shufflenetv2, Refine_mobilenetv2, Refine_mobilenetv3, '
33+
'Refine_mobilenetv3_version2, Refine_mobilenetv3_version3, Refine_resnet101, Refine_resnet101_heavy')
34+
parser.add_argument('-s', '--size', default=320, type=int, help='320, 512 (512 support Refine_hc2net_version3, Refine_resnet101, Refine_resnet101_heavy)')
35+
parser.add_argument('-d', '--dataset', default='self_dataset', help='VOC, COCO, OpenImage500, Objects365 or self dataset')
36+
parser.add_argument('--num_classes', default=5, type=int, help='number of classes, including background')
37+
## pretained model
38+
parser.add_argument('-m', '--trained_model',
39+
default='weights/Refine_hc2net_version3_320/model/Final_Refine_hc2net_version3_self_dataset.pth',
40+
type=str, help='Trained state_dict file path to open')
41+
parser.add_argument('--onnx_model',
42+
default='weights/Refine_hc2net_version3_320/model/Final_Refine_hc2net_version3_self_dataset.onnx',
43+
type=str, help='output onnx model')
44+
## post processing
45+
parser.add_argument('-n', '--nms_type', default='soft', help='nms type: normal, soft')
46+
parser.add_argument('--obj_thresh', default=0.50, type=float, help='object threshold for testing')
47+
parser.add_argument('--nms_thresh', default=0.45, type=float, help='nms threshold for testing')
48+
## src images
49+
parser.add_argument('-f', '--test_images', default='./test_images', help='test images can be folder, image or txt file')
50+
parser.add_argument('--image_nums', default=100, type=int, help='maximum number of test images, -1 means all images in test_images')
51+
parser.add_argument('--save_folder', default='eval/', type=str, help='Dir to save results')
52+
parser.add_argument('--label_list', default='./test_dataset.txt', type=str, help='test image label list')
53+
## platform
54+
parser.add_argument('--cuda', default=False, type=str2bool, help='Use cuda to train model')
55+
parser.add_argument('--inference_platform', default='pytorch', type=str, help='inference platform: caffe2, pytorch')
56+
"""
57+
58+
if __name__ == "__main__":
59+
main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tencent is pleased to support the open source community by making GameAISDK available.
4+
5+
This source code file is licensed under the GNU General Public License Version 3.
6+
For full details, please refer to the file "LICENSE.txt" which is provided as part of this source code package.
7+
8+
Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
9+
"""
10+
11+
import os
12+
import sys
13+
import platform
14+
__is_windows_system = platform.platform().lower().startswith('window')
15+
__is_linux_system = platform.platform().lower().startswith('linux')
16+
if __is_windows_system:
17+
sys.path.append(os.path.dirname(__file__))
18+
sys.path.append(os.path.join(os.path.dirname(__file__), 'windows'))
19+
from windows.detect_mutilple_images_util import main
20+
elif __is_linux_system:
21+
sys.path.append(os.path.dirname(__file__))
22+
sys.path.append(os.path.join(os.path.dirname(__file__), 'ubuntu'))
23+
from ubuntu.detect_mutilple_images_util import main
24+
else:
25+
raise Exception('system is not support!')
26+
27+
28+
"""
29+
parser.add_argument('--onnx_model',
30+
default='./weights/Refine_hc2net_version3_320/model/Refine_hc2net_version3_self_dataset_epoches_55.onnx',
31+
type=str, help='output onnx model')
32+
parser.add_argument('--trained_model',
33+
default='./weights/Refine_hc2net_version3_320/model/Refine_hc2net_version3_self_dataset_epoches_55.pth',
34+
type=str, help='output onnx model')
35+
## post processing
36+
parser.add_argument('--obj_thresh', default=0.50, type=float, help='object threshold for testing')
37+
parser.add_argument('--nms_thresh', default=0.45, type=float, help='nms threshold for testing')
38+
## src images
39+
parser.add_argument('-f', '--test_images', default='./test_UI', help='folder of test images')
40+
## show result
41+
parser.add_argument('--show_result', default=False, type=str2bool, help='Show result')
42+
"""
43+
44+
45+
if __name__ == '__main__':
46+
main()

Modules/RefineDet/detect_one_image.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tencent is pleased to support the open source community by making GameAISDK available.
4+
5+
This source code file is licensed under the GNU General Public License Version 3.
6+
For full details, please refer to the file "LICENSE.txt" which is provided as part of this source code package.
7+
8+
Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
9+
"""
10+
11+
import os
12+
import sys
13+
import platform
14+
__is_windows_system = platform.platform().lower().startswith('window')
15+
__is_linux_system = platform.platform().lower().startswith('linux')
16+
if __is_windows_system:
17+
sys.path.append(os.path.dirname(__file__))
18+
sys.path.append(os.path.join(os.path.dirname(__file__), 'windows'))
19+
from windows.detect_one_image_util import main
20+
elif __is_linux_system:
21+
sys.path.append(os.path.dirname(__file__))
22+
sys.path.append(os.path.join(os.path.dirname(__file__), 'ubuntu'))
23+
from ubuntu.detect_one_image_util import main
24+
else:
25+
raise Exception('system is not support!')
26+
27+
28+
if __name__ == '__main__':
29+
main()

Modules/RefineDet/detectmap.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tencent is pleased to support the open source community by making GameAISDK available.
4+
5+
This source code file is licensed under the GNU General Public License Version 3.
6+
For full details, please refer to the file "LICENSE.txt" which is provided as part of this source code package.
7+
8+
Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
9+
"""
10+
11+
import os
12+
import sys
13+
import platform
14+
import time
15+
__is_windows_system = platform.platform().lower().startswith('window')
16+
__is_linux_system = platform.platform().lower().startswith('linux')
17+
if __is_windows_system:
18+
sys.path.append(os.path.dirname(__file__))
19+
sys.path.append(os.path.join(os.path.dirname(__file__), 'windows'))
20+
from windows.detectmap_util import main
21+
elif __is_linux_system:
22+
sys.path.append(os.path.dirname(__file__))
23+
sys.path.append(os.path.join(os.path.dirname(__file__), 'ubuntu'))
24+
from ubuntu.detectmap_util import main
25+
else:
26+
raise Exception('system is not support!')
27+
28+
29+
"""
30+
parser.add_argument('-v', '--version', default='Refine_hc2net_version3',
31+
help='Refine_vgg, Refine_mobile, Refine_hcnet, Refine_hc2net, Refine_hc2net_version2, Refine_hc2net_version3, '
32+
'Refine_hc2net_version4, Refine_shufflenetv2, Refine_mobilenetv2, Refine_mobilenetv3, '
33+
'Refine_mobilenetv3_version2, Refine_mobilenetv3_version3, Refine_resnet101, Refine_resnet101_heavy')
34+
parser.add_argument('-s', '--size', default=320, type=int,
35+
help='320, 512 (512 support Refine_hc2net_version3, Refine_resnet101, Refine_resnet101_heavy)')
36+
parser.add_argument('-d', '--dataset', default='self_dataset ',
37+
help='VOC, COCO, OpenImage500, Objects365 or self dataset')
38+
parser.add_argument('--num_classes', default=5, type=int, help='number of classes, including background')
39+
## pretained model
40+
parser.add_argument('-m', '--trained_model',
41+
default='weights/Refine_hc2net_version3_320/model/Final_Refine_hc2net_version3_self_dataset.pth',
42+
type=str, help='Trained state_dict file path to open')
43+
parser.add_argument('--onnx_model',
44+
default='weights/Refine_hc2net_version3_320/0805/Refine_hc2net_version3_COCO_epoches_260_29.5.onnx',
45+
type=str, help='output onnx model')
46+
## post processing
47+
parser.add_argument('-n', '--nms_type', default='soft', help='nms type: normal, soft')
48+
parser.add_argument('--obj_thresh', default=0.01, type=float, help='object threshold for testing')
49+
parser.add_argument('--nms_thresh', default=0.45, type=float, help='nms threshold for testing')
50+
## src images
51+
parser.add_argument('-f', '--test_images', default='./test_images', help='test images can be folder, image or txt file')
52+
parser.add_argument('--image_nums', default=1, type=int,
53+
help='maximum number of test images, -1 means all images in test_images')
54+
parser.add_argument('--save_folder', default='./test_map', type=str, help='Dir to save results')
55+
parser.add_argument('--label_list', default='test_dataset.txt', type=str, help='test image label list')
56+
## platform
57+
parser.add_argument('--cuda', default=False, type=str2bool, help='Use cuda to train model')
58+
parser.add_argument('--inference_platform', default='pytorch', type=str, help='inference platform: caffe2, pytorch')
59+
"""
60+
61+
62+
if __name__ == "__main__":
63+
main()
64+
time.sleep(6)

Modules/RefineDet/train_val.py

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
Tencent is pleased to support the open source community by making GameAISDK available.
4+
5+
This source code file is licensed under the GNU General Public License Version 3.
6+
For full details, please refer to the file "LICENSE.txt" which is provided as part of this source code package.
7+
8+
Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
9+
"""
10+
11+
import os
12+
import sys
13+
import platform
14+
__is_windows_system = platform.platform().lower().startswith('window')
15+
__is_linux_system = platform.platform().lower().startswith('linux')
16+
if __is_windows_system:
17+
sys.path.append(os.path.dirname(__file__))
18+
sys.path.append(os.path.join(os.path.dirname(__file__), 'windows'))
19+
from windows.train_val_util import main
20+
elif __is_linux_system:
21+
sys.path.append(os.path.dirname(__file__))
22+
sys.path.append(os.path.join(os.path.dirname(__file__), 'ubuntu'))
23+
from ubuntu.train_val_util import main
24+
else:
25+
raise Exception('system is not support!')
26+
27+
28+
"""
29+
## basic configurations
30+
parser.add_argument('-v', '--version', default='Refine_hc2net_version3',
31+
help='Refine_vgg, Refine_mobile, Refine_hcnet, Refine_hc2net, Refine_hc2net_version2, Refine_hc2net_version3, '
32+
'Refine_hc2net_version4, Refine_shufflenetv2, Refine_mobilenetv2, Refine_mobilenetv3, '
33+
'Refine_mobilenetv3_version2, Refine_mobilenetv3_version3, Refine_resnet101, Refine_resnet101_heavy')
34+
parser.add_argument('-s', '--size', default=320, type=int, help='320, 512 (512 support Refine_hc2net_version3, Refine_resnet101, Refine_resnet101_heavy)')
35+
parser.add_argument('-d', '--dataset', default='self_dataset', help='VOC, COCO, OpenImage500, Objects365 or self dataset')
36+
parser.add_argument('--num_classes', default=5, type=int, help='number of classes, including background')
37+
## train and test label lists
38+
parser.add_argument('--train_label_list', default='train_dataset.txt', type=str, help='train label list')
39+
parser.add_argument('--train_image_root', default='', type=str, help='training image root for openimage dataset')
40+
parser.add_argument('--test_label_list', default='test_dataset.txt', type=str, help='test label list')
41+
parser.add_argument('--test_image_root', default='', type=str, help='testing image root for openimage dataset')
42+
## data augumentation
43+
parser.add_argument('--augment', default=False, type=str2bool, help='use data augmentation or not')
44+
parser.add_argument('--crop', default=False, type=str2bool, help='use crop for data augmentation of not ')
45+
parser.add_argument('--rotate', default=False, type=str2bool, help='use ratota for data augmentation or not')
46+
parser.add_argument('--noise', default=False, type=str2bool, help='use noise for data augmentation or not')
47+
parser.add_argument('--train_shuffle', default=True, type=str2bool, help='shuffle training data or not')
48+
## training setting
49+
parser.add_argument('-b', '--batch_size', default=16, type=int, help='Batch size for training')
50+
parser.add_argument('--num_workers', default=6, type=int, help='Number of workers used in dataloading')
51+
parser.add_argument('--cuda', default=False, type=str2bool, help='Use cuda to train model')
52+
parser.add_argument('--ngpu', default=3, type=int, help='gpus')
53+
## post processing
54+
parser.add_argument('-n', '--nms_type', default='normal', type=str, help='nms type: soft, normal')
55+
parser.add_argument('--obj_thresh', default=0.01, type=float, help='object thresh for testing')
56+
parser.add_argument('--nms_thresh', default=0.45, type=float, help='nms thresh for testing')
57+
## training tricks
58+
parser.add_argument('--weighted_classes', default=True, type=str2bool, help='use weighted classes or not')
59+
parser.add_argument('--loc_loss_type', default='giou', type=str, help='smooth_l1, giou, iou')
60+
parser.add_argument('--loss_type', default='IOUGuided_OHEM', type=str, help='OHEM, focal_loss, ghm_loss, libra, IOUGuided_OHEM, GIOUGuided_OHEM')
61+
parser.add_argument('--IOU_guided_ratio', default=0.25, type=float, help='IOU guided ratio for IOUGuided_OHEM')
62+
parser.add_argument('--weighted_IOU_Guided', default=True, type=str2bool, help='use weighted IOU guided loss or not')
63+
parser.add_argument('--uncertainty_factor', default=True, type=str2bool, help='use uncertainty factor for multitask learning')
64+
parser.add_argument('--basenet', default='./weights/Refine_hc2net_version3_self_dataset_epoches_55.pth', help='pretrained base model')
65+
## learning rate relavent
66+
parser.add_argument('--lr', '--learning-rate', default=1e-1, type=float, help='initial learning rate')
67+
parser.add_argument('--momentum', default=0.96, type=float, help='momentum')
68+
parser.add_argument('--resume_net', default=True, type=str2bool, help='resume net for retraining')
69+
parser.add_argument('--resume_epoch', default=55, type=int, help='resume iter for retraining')
70+
parser.add_argument('-max', '--max_epoch', default=60, type=int, help='max epoch for retraining')
71+
parser.add_argument('-we', '--warm_epoch', default=2, type=float, help='warm epoch for retraining')
72+
parser.add_argument('--weight_decay', default=5e-4, type=float, help='Weight decay for SGD')
73+
parser.add_argument('--gamma', default=0.1, type=float, help='Gamma update for SGD')
74+
parser.add_argument('--adjust_type', default='step', type=str, help='learning rate adjusting type: step, cosine')
75+
## loss weight
76+
parser.add_argument('--anchor_class_loss_ratio', default=1.0, type=float, help='anchor class loss ratio')
77+
parser.add_argument('--class_loss_ratio', default=1.0, type=float, help='class loss ratio')
78+
## save and print
79+
parser.add_argument('--save_folder', default='weights', help='Location to save checkpoint models')
80+
parser.add_argument('--date', default='model')
81+
parser.add_argument('--save_frequency', default=10, type=int, help='how many epoches to save model')
82+
parser.add_argument('--print_frequency', default=1, type=int, help='how many iters to print loss')
83+
parser.add_argument('--retest', default=False, type=str2bool, help='test cache results')
84+
parser.add_argument('--test_frequency', default=10, type=int, help='how many epoches to test model')
85+
## random seed
86+
parser.add_argument('--rand_seed', type=int, default=2, help='seed for torch ramdom')
87+
"""
88+
89+
90+
if __name__ == "__main__":
91+
main()
13.5 KB
Binary file not shown.
129 Bytes
Binary file not shown.
967 Bytes
Binary file not shown.
376 Bytes
Binary file not shown.
11.1 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
1
2+
1.579531322
3+
1.117189253
4+
1.492039504
5+
1.761043695
6+
1.656781425
7+
1.82556069
8+
1.441447995
9+
1.415275485
10+
1.354806288
11+
2.641755395
12+
2.584996317
13+
3.19618916
14+
1.446281337
15+
1.413537791
16+
1.798066036
17+
1.713470845
18+
1.617781078
19+
1.460337928
20+
1.518527719
21+
1.709343734
22+
3.171553198
23+
1.729171893
24+
1.751484117
25+
1.492259596
26+
1.396193369
27+
1.369175803
28+
1.625823383
29+
1.645380067
30+
2.250652085
31+
1.615841452
32+
2.265754852
33+
1.636396957
34+
1.478545949
35+
2.069258634
36+
1.966467947
37+
1.713866667
38+
1.653420792
39+
1.789675776
40+
1.205698731
41+
1.532260394
42+
1.237876467
43+
1.716651041
44+
1.540744794
45+
1.651552017
46+
1.325411651
47+
1.461600179
48+
1.679365253
49+
1.855547802
50+
1.630608937
51+
1.567578525
52+
1.533986642
53+
2.171185486
54+
1.677947969
55+
1.574070062
56+
1.631893601
57+
1.133231522
58+
1.683836579
59+
1.49652685
60+
1.885508998
61+
1.301209423
62+
1.888554088
63+
1.679099016
64+
1.769939119
65+
2.422526937
66+
1.688738943
67+
2.182054961
68+
1.629855919
69+
2.812805426
70+
2.056054014
71+
9.265382247
72+
1.702867758
73+
2.262559785
74+
1.202041869
75+
1.637090099
76+
1.615626759
77+
3.003066261
78+
1.79629654
79+
10
80+
2.613425063
1.18 KB
Binary file not shown.
10.1 KB
Binary file not shown.
10.2 KB
Binary file not shown.
20.6 KB
Binary file not shown.
1.85 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
./labeled_images/00fdfe384dfbd57dc41f6a73d6801b62.jpg 453 173 4564 3218 1
2+
./labeled_images/0130b60d005b5525730fd39b69a6f8fc.jpg 445 61 567 161 1
3+
./labeled_images/013e68e2fd1cedf730dd056b79a94360.jpg 501 126 548 176 3 1 1 550 411 5
4+
./labeled_images/011dacb4bf642701f98cee670f8c9814.jpg 33 32 410 416 4
5+
./labeled_images/00eb4738e93023ea09a5029f0480a7f6.jpg 113 122 303 286 1 169 176 266 264 2
6+
./labeled_images/00f76b75f1206d6f43580a2a47c3ac55.jpg 6 48 3592 3148 1
7+
./labeled_images/00fa71fc29c45b7b751775f7b4ba6352.jpg 308 131 508 291 1
8+
./labeled_images/00fc804e23af54d7be066e6f0ab796fd.jpg 1 1 236 122 5 1 131 235 252 5 1 258 235 379 5 238 1 474 123 5 233 138 466 260 5 232 277 489 378 5
9+
./labeled_images/01463fe0247914ad178dd09b51a6762b.jpg 1 1 552 276 5 18 16 71 73 3
10+
./labeled_images/01470289528a7fd27689701677e6b78f.jpg 43 8 195 173 3
11+
./labeled_images/014a43fbc164da14bf6dcf9df43cc69c.jpg 146 98 1345 1113 1
12+
./labeled_images/014c6df130d7e555ec50573230b5483c.jpg 385 1 652 104 2 756 1 972 132 2 763 289 984 407 2
13+
./labeled_images/014c97d988d835b02158c74740e4fb16.jpg 102 49 1171 934 1 1120 764 1250 887 1
14+
./labeled_images/0157283db571af5f8f44c4a3e27201da.jpg 16 40 164 196 4 185 29 363 190 4 379 21 557 212 4 275 214 525 441 4 33 226 256 428 4 37 44 75 82 2 202 39 242 67 2
15+
./labeled_images/01762945494f9e8b8216c94633399e34.jpg 123 27 974 871 4
Binary file not shown.
11.8 KB
Binary file not shown.
6.1 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
17.8 KB
Binary file not shown.
17.5 KB
Binary file not shown.
171 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4.49 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1.83 KB
Binary file not shown.
122 Bytes
Binary file not shown.
10.5 KB
Binary file not shown.
7.81 KB
Binary file not shown.
4.46 KB
Binary file not shown.
8.06 KB
Binary file not shown.
6.48 KB
Binary file not shown.
20.7 KB
Binary file not shown.
Binary file not shown.
121 Bytes
Binary file not shown.
17.6 KB
Binary file not shown.
420 Bytes
Binary file not shown.
125 Bytes
Binary file not shown.
Binary file not shown.
518 Bytes
Binary file not shown.
1.13 KB
Binary file not shown.
22.7 KB
Binary file not shown.
11.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
356 Bytes
Binary file not shown.
10.2 KB
Binary file not shown.
934 Bytes
Binary file not shown.
8.72 KB
Binary file not shown.
9.9 KB
Binary file not shown.
20.4 KB
Binary file not shown.
1.66 KB
Binary file not shown.

0 commit comments

Comments
 (0)