As a computer vision engineer, it was designed for my daily work
This project will be updated occasionally.
2021.10.15
- add transform setting in config.yaml
- add new arguments parser, and function update_cfg
2021.10.13
- reconstruct whole code structure
2021.2.6
- add labelsmooth flag in
config.py
andtrain.py
andutils/loss.py
2021.1.7
preprocess.py
add new column nowclass_name
- add
test_tta.py
(not finished),train_.py
(support different validation)
2021.1.5
- add
ScoreCam.py
to visualize CNN layer - add confusion_matrix to
train.py
, add new argument--cal_mtx
default isTrue
2021.1.4
- modified the
model/models
, to change theClassifier
- modified the
train.py
- modified the
test.py
2020.12.31
- update preprocess_data for easily produce csv file
- update test.py for easily doing inference
2020.12.29 upload to github
2020.12.29
- ResNet all models
- ResNest all models
- efficientNet B4
- set you image data be like :
data
| --- task_name
|---train
|---class1
|---- img1.jpg
|---- img2.jpg
|---- ....
|---class2
|---...
|--- val
|---class1
|---- img1.jpg
|---- img2.jpg
|---- ....
|---class2
|---...
2.using data_load/img2csv.py to create train and val csv file
#create train csv
python data_load/img2csv.py --img_path data/your_task_name/train/ --classes class1,class2... --csv data/your_task_name_train.csv
#create vaL csv
python data_load/img2csv.py --img_path data/your_task_name/ --classes class1,class2... --csv data/your_task_name_val.csv
you can copy a default cfg to modify it in experiments dir:
config.yaml remember to set None if you do not want to any of img transforms
fold_num: 5
seed: 719
model_arch: resnet50
img_size: 224
epochs: 100
loss: labelsmooth #BCEwithlogits, labelsmooth, c
train_batchsize: 256
valid_batchsize: 128
test_batchsize: 128 #for test tt
T_0: 10 #for cosine lr schedule
lr: 0.001
min_lr: 0.00001
weight_decay: 0.00001
num_workers: 4
accum_iter: 2 # suppoprt to do batch accumulation for backprop with effectively larger batch siz
verbose_step: 1
tta : 3
valid_every_x_epoch: 5
default_save_path: output_model
gpus : 0
# 'model_arch': "tf_efficientnet_b4_ns"
# 'model_arch': 'RepVGG-B1g2'
#img augmentation
train_aug:
HorizontalFlip : [0.5]
VerticalFlip : [0.5]
HueSaturationValue : [0.2, 0.2, 0.2, 0.5]
ShiftScaleRotate : [0.5]
CoarseDropout : [0.5]
Cutout : [0.5]
MotionBlur : [3, 0.5]
val_aug:
HorizontalFlip : None
VerticalFlip : None
HueSaturationValue : None
ShiftScaleRotate : None
CoarseDropout : [0.5]
Cutout : [0.5]
tta_aug:
HorizontalFlip : None
VerticalFlip : None
HueSaturationValue : None
ShiftScaleRotate : None
CoarseDropout : [0.5]
Cutout : [0.5]
train commnad example
python train.py --tpath data/yourtask/train/ --tcsv data/yourtask_train.csv --vpath data/yourtask/val/ --vcsv data/yourtask_val.csv --cfg experiment/config_task.yaml --bsize 128 --gpus '0,1,2,3,4,5,6,7'
-bsize
: training-batchsize-cfg
: your config yaml-gpus
: set gpu be like '0,1,2,3' ps.start from 0
- training confusion matrix
- trained weight
- tensorboard log
above will be save into output_model directory by date_modelname
not yet update
not yet update