zgcr654321 commited on
Commit
9502263
1 Parent(s): f6451f4

Upload 369 files

Browse files
Files changed (36) hide show
  1. imagenet/resnet18_dino_pretrain/__pycache__/train_config.cpython-38.pyc +0 -0
  2. imagenet/resnet18_dino_pretrain/checkpoints/latest.pth +3 -0
  3. imagenet/resnet18_dino_pretrain/checkpoints/resnet18-acc70.754.pth +3 -0
  4. imagenet/resnet18_dino_pretrain/log/train.info.log +0 -0
  5. imagenet/resnet18_dino_pretrain/log/train.info.log.2023-09-05 +0 -0
  6. imagenet/resnet18_dino_pretrain/test.sh +1 -0
  7. imagenet/resnet18_dino_pretrain/test_config.py +55 -0
  8. imagenet/resnet18_dino_pretrain/train.sh +1 -0
  9. imagenet/resnet18_dino_pretrain/train_config.py +107 -0
  10. imagenet/resnet18_vit_aug_lion_dino_pretrain/__pycache__/train_config.cpython-38.pyc +0 -0
  11. imagenet/resnet18_vit_aug_lion_dino_pretrain/checkpoints/latest.pth +3 -0
  12. imagenet/resnet18_vit_aug_lion_dino_pretrain/checkpoints/resnet18-acc71.362.pth +3 -0
  13. imagenet/resnet18_vit_aug_lion_dino_pretrain/log/train.info.log +0 -0
  14. imagenet/resnet18_vit_aug_lion_dino_pretrain/log/train.info.log.2023-09-12 +0 -0
  15. imagenet/resnet18_vit_aug_lion_dino_pretrain/test.sh +1 -0
  16. imagenet/resnet18_vit_aug_lion_dino_pretrain/test_config.py +55 -0
  17. imagenet/resnet18_vit_aug_lion_dino_pretrain/train.sh +1 -0
  18. imagenet/resnet18_vit_aug_lion_dino_pretrain/train_config.py +125 -0
  19. imagenet/resnet34_dino_pretrain/__pycache__/train_config.cpython-38.pyc +0 -0
  20. imagenet/resnet34_dino_pretrain/checkpoints/latest.pth +3 -0
  21. imagenet/resnet34_dino_pretrain/checkpoints/resnet34-acc74.218.pth +3 -0
  22. imagenet/resnet34_dino_pretrain/log/train.info.log +0 -0
  23. imagenet/resnet34_dino_pretrain/log/train.info.log.2023-09-05 +0 -0
  24. imagenet/resnet34_dino_pretrain/test.sh +1 -0
  25. imagenet/resnet34_dino_pretrain/test_config.py +55 -0
  26. imagenet/resnet34_dino_pretrain/train.sh +1 -0
  27. imagenet/resnet34_dino_pretrain/train_config.py +107 -0
  28. imagenet/resnet34_vit_aug_lion_dino_pretrain/__pycache__/train_config.cpython-38.pyc +0 -0
  29. imagenet/resnet34_vit_aug_lion_dino_pretrain/checkpoints/latest.pth +3 -0
  30. imagenet/resnet34_vit_aug_lion_dino_pretrain/checkpoints/resnet34-acc75.916.pth +3 -0
  31. imagenet/resnet34_vit_aug_lion_dino_pretrain/log/train.info.log +0 -0
  32. imagenet/resnet34_vit_aug_lion_dino_pretrain/log/train.info.log.2023-09-12 +0 -0
  33. imagenet/resnet34_vit_aug_lion_dino_pretrain/test.sh +1 -0
  34. imagenet/resnet34_vit_aug_lion_dino_pretrain/test_config.py +55 -0
  35. imagenet/resnet34_vit_aug_lion_dino_pretrain/train.sh +1 -0
  36. imagenet/resnet34_vit_aug_lion_dino_pretrain/train_config.py +125 -0
imagenet/resnet18_dino_pretrain/__pycache__/train_config.cpython-38.pyc ADDED
Binary file (2.66 kB). View file
 
imagenet/resnet18_dino_pretrain/checkpoints/latest.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:39dab92477179baf7d30671e45f352f32b2189719378df328dc239cbcf2818ee
3
+ size 93614103
imagenet/resnet18_dino_pretrain/checkpoints/resnet18-acc70.754.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:97642255c498d6fbb0ddd6d3d8d91398407850ded475c17a0b81d277ecc428e4
3
+ size 46833625
imagenet/resnet18_dino_pretrain/log/train.info.log ADDED
The diff for this file is too large to render. See raw diff
 
imagenet/resnet18_dino_pretrain/log/train.info.log.2023-09-05 ADDED
The diff for this file is too large to render. See raw diff
 
imagenet/resnet18_dino_pretrain/test.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ OMP_NUM_THREADS=1 CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.run --nproc_per_node=2 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/test_classification_model.py --work-dir ./
imagenet/resnet18_dino_pretrain/test_config.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ BASE_DIR = os.path.dirname(
5
+ os.path.dirname(os.path.dirname(os.path.dirname(
6
+ os.path.abspath(__file__)))))
7
+ sys.path.append(BASE_DIR)
8
+
9
+ from tools.path import ILSVRC2012_path
10
+
11
+ from simpleAICV.classification import backbones
12
+ from simpleAICV.classification import losses
13
+ from simpleAICV.classification.datasets.ilsvrc2012dataset import ILSVRC2012Dataset
14
+ from simpleAICV.classification.common import Opencv2PIL, TorchResize, TorchCenterCrop, TorchMeanStdNormalize, ClassificationCollater, load_state_dict
15
+
16
+ import torch
17
+ import torchvision.transforms as transforms
18
+
19
+
20
+ class config:
21
+ '''
22
+ for resnet,input_image_size = 224;for darknet,input_image_size = 256
23
+ '''
24
+ network = 'resnet18'
25
+ num_classes = 1000
26
+ input_image_size = 224
27
+ scale = 256 / 224
28
+
29
+ model = backbones.__dict__[network](**{
30
+ 'num_classes': num_classes,
31
+ })
32
+
33
+ # load pretrained model or not
34
+ trained_model_path = ''
35
+ load_state_dict(trained_model_path, model)
36
+
37
+ test_criterion = losses.__dict__['CELoss']()
38
+
39
+ test_dataset = ILSVRC2012Dataset(
40
+ root_dir=ILSVRC2012_path,
41
+ set_name='val',
42
+ transform=transforms.Compose([
43
+ Opencv2PIL(),
44
+ TorchResize(resize=input_image_size * scale),
45
+ TorchCenterCrop(resize=input_image_size),
46
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
47
+ std=[0.229, 0.224, 0.225]),
48
+ ]))
49
+ test_collater = ClassificationCollater()
50
+
51
+ seed = 0
52
+ # batch_size is total size
53
+ batch_size = 256
54
+ # num_workers is total workers
55
+ num_workers = 16
imagenet/resnet18_dino_pretrain/train.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ CUDA_VISIBLE_DEVICES=0 python -m torch.distributed.run --nproc_per_node=1 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/train_classification_model.py --work-dir ./
imagenet/resnet18_dino_pretrain/train_config.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ BASE_DIR = os.path.dirname(
5
+ os.path.dirname(os.path.dirname(os.path.dirname(
6
+ os.path.abspath(__file__)))))
7
+ sys.path.append(BASE_DIR)
8
+
9
+ from tools.path import ILSVRC2012_path
10
+
11
+ from simpleAICV.classification import backbones
12
+ from simpleAICV.classification import losses
13
+ from simpleAICV.classification.datasets.ilsvrc2012dataset import ILSVRC2012Dataset
14
+ from simpleAICV.classification.common import Opencv2PIL, TorchRandomResizedCrop, TorchRandomHorizontalFlip, TorchResize, TorchCenterCrop, TorchMeanStdNormalize, ClassificationCollater, load_state_dict
15
+
16
+ import torch
17
+ import torchvision.transforms as transforms
18
+
19
+
20
+ class config:
21
+ '''
22
+ for resnet,input_image_size = 224;for darknet,input_image_size = 256
23
+ '''
24
+ network = 'resnet18'
25
+ num_classes = 1000
26
+ input_image_size = 224
27
+ scale = 256 / 224
28
+
29
+ model = backbones.__dict__[network](**{
30
+ 'num_classes': num_classes,
31
+ })
32
+
33
+ # load pretrained model or not
34
+ trained_model_path = '/root/code/SimpleAICV_pytorch_training_examples_on_ImageNet_COCO_ADE20K/pretrained_models/resnet_dino_pretrain_on_imagenet1k/resnet18_dino_pretrain_model-student-loss3.081.pth'
35
+ load_state_dict(trained_model_path, model)
36
+
37
+ train_criterion = losses.__dict__['CELoss']()
38
+ test_criterion = losses.__dict__['CELoss']()
39
+
40
+ train_dataset = ILSVRC2012Dataset(
41
+ root_dir=ILSVRC2012_path,
42
+ set_name='train',
43
+ transform=transforms.Compose([
44
+ Opencv2PIL(),
45
+ TorchRandomResizedCrop(resize=input_image_size),
46
+ TorchRandomHorizontalFlip(prob=0.5),
47
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
48
+ std=[0.229, 0.224, 0.225]),
49
+ ]))
50
+
51
+ test_dataset = ILSVRC2012Dataset(
52
+ root_dir=ILSVRC2012_path,
53
+ set_name='val',
54
+ transform=transforms.Compose([
55
+ Opencv2PIL(),
56
+ TorchResize(resize=input_image_size * scale),
57
+ TorchCenterCrop(resize=input_image_size),
58
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
59
+ std=[0.229, 0.224, 0.225]),
60
+ ]))
61
+ train_collater = ClassificationCollater()
62
+ test_collater = ClassificationCollater()
63
+
64
+ seed = 0
65
+ # batch_size is total size
66
+ batch_size = 256
67
+ # num_workers is total workers
68
+ num_workers = 12
69
+ accumulation_steps = 1
70
+
71
+ optimizer = (
72
+ 'SGD',
73
+ {
74
+ 'lr': 0.1,
75
+ 'momentum': 0.9,
76
+ 'global_weight_decay': False,
77
+ # if global_weight_decay = False
78
+ # all bias, bn and other 1d params weight set to 0 weight decay
79
+ 'weight_decay': 1e-4,
80
+ 'no_weight_decay_layer_name_list': [],
81
+ },
82
+ )
83
+
84
+ scheduler = (
85
+ 'MultiStepLR',
86
+ {
87
+ 'warm_up_epochs': 0,
88
+ 'gamma': 0.1,
89
+ 'milestones': [30, 60, 90],
90
+ },
91
+ )
92
+
93
+ epochs = 100
94
+ print_interval = 100
95
+
96
+ sync_bn = False
97
+ use_amp = True
98
+ use_compile = False
99
+ compile_params = {
100
+ # 'default': optimizes for large models, low compile-time and no extra memory usage.
101
+ # 'reduce-overhead': optimizes to reduce the framework overhead and uses some extra memory, helps speed up small models, model update may not correct.
102
+ # 'max-autotune': optimizes to produce the fastest model, but takes a very long time to compile and may failed.
103
+ 'mode': 'default',
104
+ }
105
+
106
+ use_ema_model = False
107
+ ema_model_decay = 0.9999
imagenet/resnet18_vit_aug_lion_dino_pretrain/__pycache__/train_config.cpython-38.pyc ADDED
Binary file (3.17 kB). View file
 
imagenet/resnet18_vit_aug_lion_dino_pretrain/checkpoints/latest.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38197fc5648345b74bc25d1291aeb3dc75cc765f9be0b4ddefef2b4047f18cb7
3
+ size 93613911
imagenet/resnet18_vit_aug_lion_dino_pretrain/checkpoints/resnet18-acc71.362.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2aac6552eb8967f4824937b08d70e2810f2d95a1ba9497a557f691bb52da0f5d
3
+ size 46833625
imagenet/resnet18_vit_aug_lion_dino_pretrain/log/train.info.log ADDED
The diff for this file is too large to render. See raw diff
 
imagenet/resnet18_vit_aug_lion_dino_pretrain/log/train.info.log.2023-09-12 ADDED
The diff for this file is too large to render. See raw diff
 
imagenet/resnet18_vit_aug_lion_dino_pretrain/test.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ OMP_NUM_THREADS=1 CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.run --nproc_per_node=2 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/test_classification_model.py --work-dir ./
imagenet/resnet18_vit_aug_lion_dino_pretrain/test_config.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ BASE_DIR = os.path.dirname(
5
+ os.path.dirname(os.path.dirname(os.path.dirname(
6
+ os.path.abspath(__file__)))))
7
+ sys.path.append(BASE_DIR)
8
+
9
+ from tools.path import ILSVRC2012_path
10
+
11
+ from simpleAICV.classification import backbones
12
+ from simpleAICV.classification import losses
13
+ from simpleAICV.classification.datasets.ilsvrc2012dataset import ILSVRC2012Dataset
14
+ from simpleAICV.classification.common import Opencv2PIL, TorchResize, TorchCenterCrop, TorchMeanStdNormalize, ClassificationCollater, load_state_dict
15
+
16
+ import torch
17
+ import torchvision.transforms as transforms
18
+
19
+
20
+ class config:
21
+ '''
22
+ for resnet,input_image_size = 224;for darknet,input_image_size = 256
23
+ '''
24
+ network = 'resnet18'
25
+ num_classes = 1000
26
+ input_image_size = 224
27
+ scale = 256 / 224
28
+
29
+ model = backbones.__dict__[network](**{
30
+ 'num_classes': num_classes,
31
+ })
32
+
33
+ # load pretrained model or not
34
+ trained_model_path = ''
35
+ load_state_dict(trained_model_path, model)
36
+
37
+ test_criterion = losses.__dict__['CELoss']()
38
+
39
+ test_dataset = ILSVRC2012Dataset(
40
+ root_dir=ILSVRC2012_path,
41
+ set_name='val',
42
+ transform=transforms.Compose([
43
+ Opencv2PIL(),
44
+ TorchResize(resize=input_image_size * scale),
45
+ TorchCenterCrop(resize=input_image_size),
46
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
47
+ std=[0.229, 0.224, 0.225]),
48
+ ]))
49
+ test_collater = ClassificationCollater()
50
+
51
+ seed = 0
52
+ # batch_size is total size
53
+ batch_size = 256
54
+ # num_workers is total workers
55
+ num_workers = 16
imagenet/resnet18_vit_aug_lion_dino_pretrain/train.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ CUDA_VISIBLE_DEVICES=0 python -m torch.distributed.run --nproc_per_node=1 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/train_classification_model.py --work-dir ./
imagenet/resnet18_vit_aug_lion_dino_pretrain/train_config.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ BASE_DIR = os.path.dirname(
5
+ os.path.dirname(os.path.dirname(os.path.dirname(
6
+ os.path.abspath(__file__)))))
7
+ sys.path.append(BASE_DIR)
8
+
9
+ from tools.path import ILSVRC2012_path
10
+
11
+ from simpleAICV.classification import backbones
12
+ from simpleAICV.classification import losses
13
+ from simpleAICV.classification.datasets.ilsvrc2012dataset import ILSVRC2012Dataset
14
+ from simpleAICV.classification.common import Opencv2PIL, TorchRandomResizedCrop, TorchRandomHorizontalFlip, RandAugment, TorchResize, TorchCenterCrop, TorchMeanStdNormalize, RandomErasing, ClassificationCollater, MixupCutmixClassificationCollater, load_state_dict
15
+
16
+ import torch
17
+ import torchvision.transforms as transforms
18
+
19
+
20
+ class config:
21
+ '''
22
+ for resnet,input_image_size = 224;for darknet,input_image_size = 256
23
+ '''
24
+ network = 'resnet18'
25
+ num_classes = 1000
26
+ input_image_size = 224
27
+ scale = 256 / 224
28
+
29
+ model = backbones.__dict__[network](**{
30
+ 'num_classes': num_classes,
31
+ })
32
+
33
+ # load pretrained model or not
34
+ trained_model_path = '/root/code/SimpleAICV_pytorch_training_examples_on_ImageNet_COCO_ADE20K/pretrained_models/resnet_dino_pretrain_on_imagenet1k/resnet18_dino_pretrain_model-student-loss3.081.pth'
35
+ load_state_dict(trained_model_path, model)
36
+
37
+ train_criterion = losses.__dict__['OneHotLabelCELoss']()
38
+ test_criterion = losses.__dict__['CELoss']()
39
+
40
+ train_dataset = ILSVRC2012Dataset(
41
+ root_dir=ILSVRC2012_path,
42
+ set_name='train',
43
+ transform=transforms.Compose([
44
+ Opencv2PIL(),
45
+ TorchRandomResizedCrop(resize=input_image_size),
46
+ TorchRandomHorizontalFlip(prob=0.5),
47
+ RandAugment(magnitude=9,
48
+ num_layers=2,
49
+ resize=input_image_size,
50
+ mean=[0.485, 0.456, 0.406],
51
+ integer=True,
52
+ weight_idx=None,
53
+ magnitude_std=0.5,
54
+ magnitude_max=None),
55
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
56
+ std=[0.229, 0.224, 0.225]),
57
+ RandomErasing(prob=0.25, mode='pixel', max_count=1),
58
+ ]))
59
+
60
+ test_dataset = ILSVRC2012Dataset(
61
+ root_dir=ILSVRC2012_path,
62
+ set_name='val',
63
+ transform=transforms.Compose([
64
+ Opencv2PIL(),
65
+ TorchResize(resize=input_image_size * scale),
66
+ TorchCenterCrop(resize=input_image_size),
67
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
68
+ std=[0.229, 0.224, 0.225]),
69
+ ]))
70
+
71
+ train_collater = MixupCutmixClassificationCollater(
72
+ use_mixup=True,
73
+ mixup_alpha=0.8,
74
+ cutmix_alpha=1.0,
75
+ cutmix_minmax=None,
76
+ mixup_cutmix_prob=1.0,
77
+ switch_to_cutmix_prob=0.5,
78
+ mode='batch',
79
+ correct_lam=True,
80
+ label_smoothing=0.1,
81
+ num_classes=1000)
82
+ test_collater = ClassificationCollater()
83
+
84
+ seed = 0
85
+ # batch_size is total size
86
+ batch_size = 256
87
+ # num_workers is total workers
88
+ num_workers = 12
89
+ accumulation_steps = 16
90
+
91
+ optimizer = (
92
+ 'Lion',
93
+ {
94
+ 'lr': 4e-4,
95
+ 'global_weight_decay': False,
96
+ # if global_weight_decay = False
97
+ # all bias, bn and other 1d params weight set to 0 weight decay
98
+ 'weight_decay': 1e-4,
99
+ 'no_weight_decay_layer_name_list': [],
100
+ },
101
+ )
102
+
103
+ scheduler = (
104
+ 'CosineLR',
105
+ {
106
+ 'warm_up_epochs': 5,
107
+ 'min_lr': 1e-6,
108
+ },
109
+ )
110
+
111
+ epochs = 300
112
+ print_interval = 10
113
+
114
+ sync_bn = False
115
+ use_amp = False
116
+ use_compile = False
117
+ compile_params = {
118
+ # 'default': optimizes for large models, low compile-time and no extra memory usage.
119
+ # 'reduce-overhead': optimizes to reduce the framework overhead and uses some extra memory, helps speed up small models, model update may not correct.
120
+ # 'max-autotune': optimizes to produce the fastest model, but takes a very long time to compile and may failed.
121
+ 'mode': 'default',
122
+ }
123
+
124
+ use_ema_model = False
125
+ ema_model_decay = 0.9999
imagenet/resnet34_dino_pretrain/__pycache__/train_config.cpython-38.pyc ADDED
Binary file (2.66 kB). View file
 
imagenet/resnet34_dino_pretrain/checkpoints/latest.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa38f299648300ef6fae63c1e59a41ee7cf44cf72404bee6fb6f6dc29e568635
3
+ size 174559527
imagenet/resnet34_dino_pretrain/checkpoints/resnet34-acc74.218.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:252bacee48f03193926ff3f585f5aa4b5683022f88df1e817f242c8c48920d98
3
+ size 87325369
imagenet/resnet34_dino_pretrain/log/train.info.log ADDED
The diff for this file is too large to render. See raw diff
 
imagenet/resnet34_dino_pretrain/log/train.info.log.2023-09-05 ADDED
The diff for this file is too large to render. See raw diff
 
imagenet/resnet34_dino_pretrain/test.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ OMP_NUM_THREADS=1 CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.run --nproc_per_node=2 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/test_classification_model.py --work-dir ./
imagenet/resnet34_dino_pretrain/test_config.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ BASE_DIR = os.path.dirname(
5
+ os.path.dirname(os.path.dirname(os.path.dirname(
6
+ os.path.abspath(__file__)))))
7
+ sys.path.append(BASE_DIR)
8
+
9
+ from tools.path import ILSVRC2012_path
10
+
11
+ from simpleAICV.classification import backbones
12
+ from simpleAICV.classification import losses
13
+ from simpleAICV.classification.datasets.ilsvrc2012dataset import ILSVRC2012Dataset
14
+ from simpleAICV.classification.common import Opencv2PIL, TorchResize, TorchCenterCrop, TorchMeanStdNormalize, ClassificationCollater, load_state_dict
15
+
16
+ import torch
17
+ import torchvision.transforms as transforms
18
+
19
+
20
+ class config:
21
+ '''
22
+ for resnet,input_image_size = 224;for darknet,input_image_size = 256
23
+ '''
24
+ network = 'resnet34'
25
+ num_classes = 1000
26
+ input_image_size = 224
27
+ scale = 256 / 224
28
+
29
+ model = backbones.__dict__[network](**{
30
+ 'num_classes': num_classes,
31
+ })
32
+
33
+ # load pretrained model or not
34
+ trained_model_path = ''
35
+ load_state_dict(trained_model_path, model)
36
+
37
+ test_criterion = losses.__dict__['CELoss']()
38
+
39
+ test_dataset = ILSVRC2012Dataset(
40
+ root_dir=ILSVRC2012_path,
41
+ set_name='val',
42
+ transform=transforms.Compose([
43
+ Opencv2PIL(),
44
+ TorchResize(resize=input_image_size * scale),
45
+ TorchCenterCrop(resize=input_image_size),
46
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
47
+ std=[0.229, 0.224, 0.225]),
48
+ ]))
49
+ test_collater = ClassificationCollater()
50
+
51
+ seed = 0
52
+ # batch_size is total size
53
+ batch_size = 256
54
+ # num_workers is total workers
55
+ num_workers = 16
imagenet/resnet34_dino_pretrain/train.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ CUDA_VISIBLE_DEVICES=0 python -m torch.distributed.run --nproc_per_node=1 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/train_classification_model.py --work-dir ./
imagenet/resnet34_dino_pretrain/train_config.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ BASE_DIR = os.path.dirname(
5
+ os.path.dirname(os.path.dirname(os.path.dirname(
6
+ os.path.abspath(__file__)))))
7
+ sys.path.append(BASE_DIR)
8
+
9
+ from tools.path import ILSVRC2012_path
10
+
11
+ from simpleAICV.classification import backbones
12
+ from simpleAICV.classification import losses
13
+ from simpleAICV.classification.datasets.ilsvrc2012dataset import ILSVRC2012Dataset
14
+ from simpleAICV.classification.common import Opencv2PIL, TorchRandomResizedCrop, TorchRandomHorizontalFlip, TorchResize, TorchCenterCrop, TorchMeanStdNormalize, ClassificationCollater, load_state_dict
15
+
16
+ import torch
17
+ import torchvision.transforms as transforms
18
+
19
+
20
+ class config:
21
+ '''
22
+ for resnet,input_image_size = 224;for darknet,input_image_size = 256
23
+ '''
24
+ network = 'resnet34'
25
+ num_classes = 1000
26
+ input_image_size = 224
27
+ scale = 256 / 224
28
+
29
+ model = backbones.__dict__[network](**{
30
+ 'num_classes': num_classes,
31
+ })
32
+
33
+ # load pretrained model or not
34
+ trained_model_path = '/root/code/SimpleAICV_pytorch_training_examples_on_ImageNet_COCO_ADE20K/pretrained_models/resnet_dino_pretrain_on_imagenet1k/resnet34_dino_pretrain_model-student-loss2.425.pth'
35
+ load_state_dict(trained_model_path, model)
36
+
37
+ train_criterion = losses.__dict__['CELoss']()
38
+ test_criterion = losses.__dict__['CELoss']()
39
+
40
+ train_dataset = ILSVRC2012Dataset(
41
+ root_dir=ILSVRC2012_path,
42
+ set_name='train',
43
+ transform=transforms.Compose([
44
+ Opencv2PIL(),
45
+ TorchRandomResizedCrop(resize=input_image_size),
46
+ TorchRandomHorizontalFlip(prob=0.5),
47
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
48
+ std=[0.229, 0.224, 0.225]),
49
+ ]))
50
+
51
+ test_dataset = ILSVRC2012Dataset(
52
+ root_dir=ILSVRC2012_path,
53
+ set_name='val',
54
+ transform=transforms.Compose([
55
+ Opencv2PIL(),
56
+ TorchResize(resize=input_image_size * scale),
57
+ TorchCenterCrop(resize=input_image_size),
58
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
59
+ std=[0.229, 0.224, 0.225]),
60
+ ]))
61
+ train_collater = ClassificationCollater()
62
+ test_collater = ClassificationCollater()
63
+
64
+ seed = 0
65
+ # batch_size is total size
66
+ batch_size = 256
67
+ # num_workers is total workers
68
+ num_workers = 12
69
+ accumulation_steps = 1
70
+
71
+ optimizer = (
72
+ 'SGD',
73
+ {
74
+ 'lr': 0.1,
75
+ 'momentum': 0.9,
76
+ 'global_weight_decay': False,
77
+ # if global_weight_decay = False
78
+ # all bias, bn and other 1d params weight set to 0 weight decay
79
+ 'weight_decay': 1e-4,
80
+ 'no_weight_decay_layer_name_list': [],
81
+ },
82
+ )
83
+
84
+ scheduler = (
85
+ 'MultiStepLR',
86
+ {
87
+ 'warm_up_epochs': 0,
88
+ 'gamma': 0.1,
89
+ 'milestones': [30, 60, 90],
90
+ },
91
+ )
92
+
93
+ epochs = 100
94
+ print_interval = 100
95
+
96
+ sync_bn = False
97
+ use_amp = True
98
+ use_compile = False
99
+ compile_params = {
100
+ # 'default': optimizes for large models, low compile-time and no extra memory usage.
101
+ # 'reduce-overhead': optimizes to reduce the framework overhead and uses some extra memory, helps speed up small models, model update may not correct.
102
+ # 'max-autotune': optimizes to produce the fastest model, but takes a very long time to compile and may failed.
103
+ 'mode': 'default',
104
+ }
105
+
106
+ use_ema_model = False
107
+ ema_model_decay = 0.9999
imagenet/resnet34_vit_aug_lion_dino_pretrain/__pycache__/train_config.cpython-38.pyc ADDED
Binary file (3.17 kB). View file
 
imagenet/resnet34_vit_aug_lion_dino_pretrain/checkpoints/latest.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bdd1263db3e8894b16180c2702546cf31600473bb196b7b33422c5f7f46da551
3
+ size 174559399
imagenet/resnet34_vit_aug_lion_dino_pretrain/checkpoints/resnet34-acc75.916.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06f7e7e7bf95b527b57211cabd133ce3e4121886882dd2e238aea1e08b9bd95c
3
+ size 87325369
imagenet/resnet34_vit_aug_lion_dino_pretrain/log/train.info.log ADDED
The diff for this file is too large to render. See raw diff
 
imagenet/resnet34_vit_aug_lion_dino_pretrain/log/train.info.log.2023-09-12 ADDED
The diff for this file is too large to render. See raw diff
 
imagenet/resnet34_vit_aug_lion_dino_pretrain/test.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ OMP_NUM_THREADS=1 CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.run --nproc_per_node=2 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/test_classification_model.py --work-dir ./
imagenet/resnet34_vit_aug_lion_dino_pretrain/test_config.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ BASE_DIR = os.path.dirname(
5
+ os.path.dirname(os.path.dirname(os.path.dirname(
6
+ os.path.abspath(__file__)))))
7
+ sys.path.append(BASE_DIR)
8
+
9
+ from tools.path import ILSVRC2012_path
10
+
11
+ from simpleAICV.classification import backbones
12
+ from simpleAICV.classification import losses
13
+ from simpleAICV.classification.datasets.ilsvrc2012dataset import ILSVRC2012Dataset
14
+ from simpleAICV.classification.common import Opencv2PIL, TorchResize, TorchCenterCrop, TorchMeanStdNormalize, ClassificationCollater, load_state_dict
15
+
16
+ import torch
17
+ import torchvision.transforms as transforms
18
+
19
+
20
+ class config:
21
+ '''
22
+ for resnet,input_image_size = 224;for darknet,input_image_size = 256
23
+ '''
24
+ network = 'resnet34'
25
+ num_classes = 1000
26
+ input_image_size = 224
27
+ scale = 256 / 224
28
+
29
+ model = backbones.__dict__[network](**{
30
+ 'num_classes': num_classes,
31
+ })
32
+
33
+ # load pretrained model or not
34
+ trained_model_path = ''
35
+ load_state_dict(trained_model_path, model)
36
+
37
+ test_criterion = losses.__dict__['CELoss']()
38
+
39
+ test_dataset = ILSVRC2012Dataset(
40
+ root_dir=ILSVRC2012_path,
41
+ set_name='val',
42
+ transform=transforms.Compose([
43
+ Opencv2PIL(),
44
+ TorchResize(resize=input_image_size * scale),
45
+ TorchCenterCrop(resize=input_image_size),
46
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
47
+ std=[0.229, 0.224, 0.225]),
48
+ ]))
49
+ test_collater = ClassificationCollater()
50
+
51
+ seed = 0
52
+ # batch_size is total size
53
+ batch_size = 256
54
+ # num_workers is total workers
55
+ num_workers = 16
imagenet/resnet34_vit_aug_lion_dino_pretrain/train.sh ADDED
@@ -0,0 +1 @@
 
 
1
+ CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.run --nproc_per_node=2 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/train_classification_model.py --work-dir ./
imagenet/resnet34_vit_aug_lion_dino_pretrain/train_config.py ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ BASE_DIR = os.path.dirname(
5
+ os.path.dirname(os.path.dirname(os.path.dirname(
6
+ os.path.abspath(__file__)))))
7
+ sys.path.append(BASE_DIR)
8
+
9
+ from tools.path import ILSVRC2012_path
10
+
11
+ from simpleAICV.classification import backbones
12
+ from simpleAICV.classification import losses
13
+ from simpleAICV.classification.datasets.ilsvrc2012dataset import ILSVRC2012Dataset
14
+ from simpleAICV.classification.common import Opencv2PIL, TorchRandomResizedCrop, TorchRandomHorizontalFlip, RandAugment, TorchResize, TorchCenterCrop, TorchMeanStdNormalize, RandomErasing, ClassificationCollater, MixupCutmixClassificationCollater, load_state_dict
15
+
16
+ import torch
17
+ import torchvision.transforms as transforms
18
+
19
+
20
+ class config:
21
+ '''
22
+ for resnet,input_image_size = 224;for darknet,input_image_size = 256
23
+ '''
24
+ network = 'resnet34'
25
+ num_classes = 1000
26
+ input_image_size = 224
27
+ scale = 256 / 224
28
+
29
+ model = backbones.__dict__[network](**{
30
+ 'num_classes': num_classes,
31
+ })
32
+
33
+ # load pretrained model or not
34
+ trained_model_path = '/root/code/SimpleAICV_pytorch_training_examples_on_ImageNet_COCO_ADE20K/pretrained_models/resnet_dino_pretrain_on_imagenet1k/resnet34_dino_pretrain_model-student-loss2.425.pth'
35
+ load_state_dict(trained_model_path, model)
36
+
37
+ train_criterion = losses.__dict__['OneHotLabelCELoss']()
38
+ test_criterion = losses.__dict__['CELoss']()
39
+
40
+ train_dataset = ILSVRC2012Dataset(
41
+ root_dir=ILSVRC2012_path,
42
+ set_name='train',
43
+ transform=transforms.Compose([
44
+ Opencv2PIL(),
45
+ TorchRandomResizedCrop(resize=input_image_size),
46
+ TorchRandomHorizontalFlip(prob=0.5),
47
+ RandAugment(magnitude=9,
48
+ num_layers=2,
49
+ resize=input_image_size,
50
+ mean=[0.485, 0.456, 0.406],
51
+ integer=True,
52
+ weight_idx=None,
53
+ magnitude_std=0.5,
54
+ magnitude_max=None),
55
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
56
+ std=[0.229, 0.224, 0.225]),
57
+ RandomErasing(prob=0.25, mode='pixel', max_count=1),
58
+ ]))
59
+
60
+ test_dataset = ILSVRC2012Dataset(
61
+ root_dir=ILSVRC2012_path,
62
+ set_name='val',
63
+ transform=transforms.Compose([
64
+ Opencv2PIL(),
65
+ TorchResize(resize=input_image_size * scale),
66
+ TorchCenterCrop(resize=input_image_size),
67
+ TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
68
+ std=[0.229, 0.224, 0.225]),
69
+ ]))
70
+
71
+ train_collater = MixupCutmixClassificationCollater(
72
+ use_mixup=True,
73
+ mixup_alpha=0.8,
74
+ cutmix_alpha=1.0,
75
+ cutmix_minmax=None,
76
+ mixup_cutmix_prob=1.0,
77
+ switch_to_cutmix_prob=0.5,
78
+ mode='batch',
79
+ correct_lam=True,
80
+ label_smoothing=0.1,
81
+ num_classes=1000)
82
+ test_collater = ClassificationCollater()
83
+
84
+ seed = 0
85
+ # batch_size is total size
86
+ batch_size = 256
87
+ # num_workers is total workers
88
+ num_workers = 24
89
+ accumulation_steps = 16
90
+
91
+ optimizer = (
92
+ 'Lion',
93
+ {
94
+ 'lr': 4e-4,
95
+ 'global_weight_decay': False,
96
+ # if global_weight_decay = False
97
+ # all bias, bn and other 1d params weight set to 0 weight decay
98
+ 'weight_decay': 1e-4,
99
+ 'no_weight_decay_layer_name_list': [],
100
+ },
101
+ )
102
+
103
+ scheduler = (
104
+ 'CosineLR',
105
+ {
106
+ 'warm_up_epochs': 5,
107
+ 'min_lr': 1e-6,
108
+ },
109
+ )
110
+
111
+ epochs = 300
112
+ print_interval = 10
113
+
114
+ sync_bn = False
115
+ use_amp = False
116
+ use_compile = False
117
+ compile_params = {
118
+ # 'default': optimizes for large models, low compile-time and no extra memory usage.
119
+ # 'reduce-overhead': optimizes to reduce the framework overhead and uses some extra memory, helps speed up small models, model update may not correct.
120
+ # 'max-autotune': optimizes to produce the fastest model, but takes a very long time to compile and may failed.
121
+ 'mode': 'default',
122
+ }
123
+
124
+ use_ema_model = False
125
+ ema_model_decay = 0.9999