Diff of /README.md [000000] .. [4e96d3]

Switch to unified view

a b/README.md
1
### Introduction
2
3
Hello!
4
5
Below you can find a outline of how to reproduce my solution for the [UW-Madison GI Tract Image Segmentation | Kaggle](https://www.kaggle.com/competitions/uw-madison-gi-tract-image-segmentation/discussion/337197#1864282)
6
7
If you run into any trouble with the setup/code or have any questions please contact me at 273806108@qq.com
8
9
10
11
### Contents
12
13
```sh
14
preprocess.py: data preprocessing codes
15
inference.py: inferencing codes
16
other: necessary codes for `mmsegmentation` and `monai` toolboxes
17
```
18
19
20
21
### Hardware
22
23
```sh
24
Ubuntu 16.04 LTS (512 GB boot disk)
25
48 x Intel(R) Xeon(R) Gold 5118 CPU @ 2.30GHz
26
126 GB Memory
27
4 x NVIDIA Titan RTX
28
```
29
30
### Software
31
32
```sh
33
python==3.7.10
34
CUDA==10.2
35
cudnn==7.6.5
36
nvidia-drivers==440.4
37
(other refer to ./requirements.txt)
38
```
39
40
### Data setup
41
42
```sh
43
# DOWNLOAD DATA
44
kaggle competitions download -c uw-madison-gi-tract-image-segmentation
45
46
mkdir -p ./data/tract
47
mv uw-madison-gi-tract-image-segmentation.zip ./data/tract
48
49
cd ./data/tract
50
unzip uw-madison-gi-tract-image-segmentation.zip
51
cd ../..
52
```
53
54
55
The expected after unzip should be:
56
57
```sh
58
./data/tract
59
        ├── sample_submission.csv
60
        ├── test
61
        ├── train
62
        ├── train.csv
63
```
64
Install base requirements, `mmsegmentation` and `monai` toolboxes
65
66
```sh
67
# INSTALL PYTHON REQUIREMENTS
68
pip install -r requirements.txt
69
pip install "monai[ignite,skimage,nibabel]==0.8.1"
70
pip install mmcv-full==1.3.17 --force-reinstall -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.10.0/index.html
71
pip install -v -e .
72
```
73
74
### Data preprocess
75
76
```sh
77
python data_preprocess.py
78
```
79
80
### Training
81
82
> NOTE: **make sure internet connection for public pretrained weights downloading**
83
84
```sh
85
mkdir -p saved_weights/cls saved_weights/seg saved_weights/3d
86
87
# DOWNLOAD PRETRAINED WEIGHTS
88
mkdir weights
89
cd weights
90
wget https://dl.fbaipublicfiles.com/convnext/ade20k/convnext_base_22k_224.pth
91
wget https://dl.fbaipublicfiles.com/convnext/ade20k/convnext_small_1k_224_ema.pth
92
cd ..
93
94
# TRAIN CLASSIFICATION MODELS
95
id=1
96
for config in $(find ./work_configs/tract/final_solution/classification_configs/cls*.py | sort); do
97
    ./tools/dist_train.sh $config 2
98
    last_work_dir=$(ls ./work_dirs/tract/ -rt | tail -n 1)
99
    last_weight=$(ls ./work_dirs/tract/$last_work_dir/*.pth -rt | tail -n 1)
100
    last_config=$(ls ./work_dirs/tract/$last_work_dir/*.py -rt | tail -n 1)
101
    mv ./work_dirs/tract/$last_work_dir/$last_weight ./saved_weights/cls/cls_${id}.pth
102
    mv ./work_dirs/tract/$last_work_dir/$last_config ./saved_weights/cls/cls_${id}.py
103
    id=$[id+1]
104
done
105
106
# TRAIN SEGMENTATION MODELS
107
id=1
108
for config in $(find ./work_configs/tract/final_solution/segmentation_configs/seg*.py | sort); do
109
    ./tools/dist_train.sh $config 2
110
    last_work_dir=$(ls ./work_dirs/tract/ -rt | tail -n 1)
111
    last_weight=$(ls ./work_dirs/tract/$last_work_dir/*.pth -rt | tail -n 1)
112
    last_config=$(ls ./work_dirs/tract/$last_work_dir/*.py -rt | tail -n 1)
113
    mv ./work_dirs/tract/$last_work_dir/$last_weight ./saved_weights/seg/seg_${id}.pth
114
    mv ./work_dirs/tract/$last_work_dir/$last_config ./saved_weights/seg/seg_${id}.py
115
    id=$[id+1]
116
done
117
118
# TRAIN 3D MODELS
119
cd ./monai
120
fold=-1
121
for n in (12 20 32); do
122
    mkdir -p  ./output/segres${n}_all/all
123
    python multilabel_train.py \
124
        -c segres${n}_all \
125
        -f $fold \
126
        > ./output/segres${n}_all/all/output.txt
127
        
128
    mkdir -p  ./output/segres${n}_all_round2/all
129
    python multilabel_train.py \
130
        -c segres${n}_all_round2 \
131
        -f $fold \
132
        -w ./output/segres${n}_all/all/last.pth \
133
        > ./output/segres${n}_all_round2/all/output.txt
134
    mv ./output/segres${n}_all_round2/all/last.pth ../saved_weights/3d/segres${n}.pth
135
done
136
cd ..
137
```
138
139
### Inferencing
140
141
```
142
python inference.py
143
```
144
145
146
147
148