zgcr654321
commited on
Commit
•
f6451f4
1
Parent(s):
e9b55c8
Upload 8 files
Browse files- imagenet/vit_tiny_patch16_lion_for_mae_pretrain/__pycache__/train_config.cpython-38.pyc +0 -0
- imagenet/vit_tiny_patch16_lion_for_mae_pretrain/checkpoints/latest.pth +3 -0
- imagenet/vit_tiny_patch16_lion_for_mae_pretrain/checkpoints/vit_tiny_patch16-acc68.614.pth +3 -0
- imagenet/vit_tiny_patch16_lion_for_mae_pretrain/log/train.info.log +0 -0
- imagenet/vit_tiny_patch16_lion_for_mae_pretrain/test.sh +1 -0
- imagenet/vit_tiny_patch16_lion_for_mae_pretrain/test_config.py +57 -0
- imagenet/vit_tiny_patch16_lion_for_mae_pretrain/train.sh +1 -0
- imagenet/vit_tiny_patch16_lion_for_mae_pretrain/train_config.py +140 -0
imagenet/vit_tiny_patch16_lion_for_mae_pretrain/__pycache__/train_config.cpython-38.pyc
ADDED
Binary file (3.33 kB). View file
|
|
imagenet/vit_tiny_patch16_lion_for_mae_pretrain/checkpoints/latest.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:943d722e66681f77a60189365a01aa8b25bb4181725bde55afad0bdbcc68a9d5
|
3 |
+
size 45900719
|
imagenet/vit_tiny_patch16_lion_for_mae_pretrain/checkpoints/vit_tiny_patch16-acc68.614.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5caf604d12a2beb6776fdf051c5a176c81b088c8f2c2e1c9fff444a0897eb5d4
|
3 |
+
size 22915267
|
imagenet/vit_tiny_patch16_lion_for_mae_pretrain/log/train.info.log
ADDED
The diff for this file is too large to render.
See raw diff
|
|
imagenet/vit_tiny_patch16_lion_for_mae_pretrain/test.sh
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
OMP_NUM_THREADS=1 CUDA_VISIBLE_DEVICES=0 python -m torch.distributed.run --nproc_per_node=1 --master_addr 127.0.1.0 --master_port 10000 ../../../tools/test_classification_model.py --work-dir ./
|
imagenet/vit_tiny_patch16_lion_for_mae_pretrain/test_config.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = 'vit_tiny_patch16'
|
25 |
+
num_classes = 1000
|
26 |
+
input_image_size = 224
|
27 |
+
scale = 256 / 224
|
28 |
+
|
29 |
+
model = backbones.__dict__[network](**{
|
30 |
+
'image_size': 224,
|
31 |
+
'global_pool': True,
|
32 |
+
'num_classes': num_classes,
|
33 |
+
})
|
34 |
+
|
35 |
+
# load pretrained model or not
|
36 |
+
trained_model_path = ''
|
37 |
+
load_state_dict(trained_model_path, model)
|
38 |
+
|
39 |
+
test_criterion = losses.__dict__['CELoss']()
|
40 |
+
|
41 |
+
test_dataset = ILSVRC2012Dataset(
|
42 |
+
root_dir=ILSVRC2012_path,
|
43 |
+
set_name='val',
|
44 |
+
transform=transforms.Compose([
|
45 |
+
Opencv2PIL(),
|
46 |
+
TorchResize(resize=input_image_size * scale),
|
47 |
+
TorchCenterCrop(resize=input_image_size),
|
48 |
+
TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
|
49 |
+
std=[0.229, 0.224, 0.225]),
|
50 |
+
]))
|
51 |
+
test_collater = ClassificationCollater()
|
52 |
+
|
53 |
+
seed = 0
|
54 |
+
# batch_size is total size
|
55 |
+
batch_size = 256
|
56 |
+
# num_workers is total workers
|
57 |
+
num_workers = 10
|
imagenet/vit_tiny_patch16_lion_for_mae_pretrain/train.sh
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
OMP_NUM_THREADS=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/vit_tiny_patch16_lion_for_mae_pretrain/train_config.py
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
network = 'vit_tiny_patch16'
|
22 |
+
num_classes = 1000
|
23 |
+
input_image_size = 224
|
24 |
+
scale = 256 / 224
|
25 |
+
|
26 |
+
model = backbones.__dict__[network](**{
|
27 |
+
'image_size': 224,
|
28 |
+
'drop_path_prob': 0.1,
|
29 |
+
'global_pool': True,
|
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/vit_mae_pretrain_on_imagenet1k/vit_tiny_patch16_224_mae_pretrain_model-loss0.427_encoder.pth'
|
35 |
+
load_state_dict(trained_model_path,
|
36 |
+
model,
|
37 |
+
loading_new_input_size_position_encoding_weight=True)
|
38 |
+
|
39 |
+
train_criterion = losses.__dict__['OneHotLabelCELoss']()
|
40 |
+
test_criterion = losses.__dict__['CELoss']()
|
41 |
+
|
42 |
+
train_dataset = ILSVRC2012Dataset(
|
43 |
+
root_dir=ILSVRC2012_path,
|
44 |
+
set_name='train',
|
45 |
+
transform=transforms.Compose([
|
46 |
+
Opencv2PIL(),
|
47 |
+
TorchRandomResizedCrop(resize=input_image_size),
|
48 |
+
TorchRandomHorizontalFlip(prob=0.5),
|
49 |
+
RandAugment(magnitude=9,
|
50 |
+
num_layers=2,
|
51 |
+
resize=input_image_size,
|
52 |
+
mean=[0.485, 0.456, 0.406],
|
53 |
+
integer=True,
|
54 |
+
weight_idx=None,
|
55 |
+
magnitude_std=0.5,
|
56 |
+
magnitude_max=None),
|
57 |
+
TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
|
58 |
+
std=[0.229, 0.224, 0.225]),
|
59 |
+
RandomErasing(prob=0.25, mode='pixel', max_count=1),
|
60 |
+
]))
|
61 |
+
|
62 |
+
test_dataset = ILSVRC2012Dataset(
|
63 |
+
root_dir=ILSVRC2012_path,
|
64 |
+
set_name='val',
|
65 |
+
transform=transforms.Compose([
|
66 |
+
Opencv2PIL(),
|
67 |
+
TorchResize(resize=input_image_size * scale),
|
68 |
+
TorchCenterCrop(resize=input_image_size),
|
69 |
+
TorchMeanStdNormalize(mean=[0.485, 0.456, 0.406],
|
70 |
+
std=[0.229, 0.224, 0.225]),
|
71 |
+
]))
|
72 |
+
|
73 |
+
train_collater = MixupCutmixClassificationCollater(
|
74 |
+
use_mixup=True,
|
75 |
+
mixup_alpha=0.8,
|
76 |
+
cutmix_alpha=1.0,
|
77 |
+
cutmix_minmax=None,
|
78 |
+
mixup_cutmix_prob=1.0,
|
79 |
+
switch_to_cutmix_prob=0.5,
|
80 |
+
mode='batch',
|
81 |
+
correct_lam=True,
|
82 |
+
label_smoothing=0.1,
|
83 |
+
num_classes=1000)
|
84 |
+
test_collater = ClassificationCollater()
|
85 |
+
|
86 |
+
seed = 0
|
87 |
+
# batch_size is total size
|
88 |
+
batch_size = 512
|
89 |
+
# num_workers is total workers
|
90 |
+
num_workers = 10
|
91 |
+
accumulation_steps = 8
|
92 |
+
|
93 |
+
optimizer = (
|
94 |
+
'Lion',
|
95 |
+
{
|
96 |
+
'lr':
|
97 |
+
4e-4,
|
98 |
+
'global_weight_decay':
|
99 |
+
False,
|
100 |
+
# if global_weight_decay = False
|
101 |
+
# all bias, bn and other 1d params weight set to 0 weight decay
|
102 |
+
'weight_decay':
|
103 |
+
5e-2,
|
104 |
+
# lr_layer_decay only support vit style model
|
105 |
+
'lr_layer_decay':
|
106 |
+
0.65,
|
107 |
+
'lr_layer_decay_block':
|
108 |
+
model.blocks,
|
109 |
+
'block_name':
|
110 |
+
'blocks',
|
111 |
+
'no_weight_decay_layer_name_list': [
|
112 |
+
'position_encoding',
|
113 |
+
'cls_token',
|
114 |
+
],
|
115 |
+
},
|
116 |
+
)
|
117 |
+
|
118 |
+
scheduler = (
|
119 |
+
'CosineLR',
|
120 |
+
{
|
121 |
+
'warm_up_epochs': 5,
|
122 |
+
'min_lr': 1e-6,
|
123 |
+
},
|
124 |
+
)
|
125 |
+
|
126 |
+
epochs = 100
|
127 |
+
print_interval = 10
|
128 |
+
|
129 |
+
sync_bn = False
|
130 |
+
use_amp = True
|
131 |
+
use_compile = False
|
132 |
+
compile_params = {
|
133 |
+
# 'default': optimizes for large models, low compile-time and no extra memory usage.
|
134 |
+
# 'reduce-overhead': optimizes to reduce the framework overhead and uses some extra memory, helps speed up small models, model update may not correct.
|
135 |
+
# 'max-autotune': optimizes to produce the fastest model, but takes a very long time to compile and may failed.
|
136 |
+
'mode': 'default',
|
137 |
+
}
|
138 |
+
|
139 |
+
use_ema_model = False
|
140 |
+
ema_model_decay = 0.9999
|