-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_predeval.py
118 lines (102 loc) · 5.08 KB
/
run_predeval.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import os
import sys
import glob
from pathlib import Path
# base = """CUDA_VISIBLE_DEVICES=2 python main.py \
# --lr 1e-6 \
# --use_cropimg=False \
# --auto_resume=False \
# --drop_path 0.2 \
# --layer_decay 0.8 \
# --test_val_ratio 0.0 0.2 \
# --nb_classes 2 \
# --use_softlabel True \
# --use_class 0 \
# --pred True \
# --pred_eval True \
# --eval_data_path '../nasdata/trainset/01st_data' \
# --eval_not_include_neg True"""
base = """python main.py \
--model convnext_base \
--lr 1e-6 \
--use_cropimg=False \
--auto_resume=False \
--drop_path 0.2 \
--layer_decay 0.8 \
--test_val_ratio 0.0 1.0 \
--use_softlabel True \
--use_class 0 \
--pred_eval True \
--pred True \
--path_type true --txt_type false \
--eval_data_path ../nasdata/20230731_Seoul_Data/dataset_20230713 \
--pred_save True \
--pred_save_with_conf False \
--use_cropimg False \
--conf 97.0"""
# ../nasdata/20230731_Seoul_Data/dataset_20230713
# ../nasdata/20230731_Seoul_Data_positive/dataset_20230713
# ../nasdata/trainset_2/230823_dataset_pothole_seoul
# ../nasdata/crop_trainset_2/230823_dataset_pothole_seoul
# nb_classes가 2이면 --use_softlabel=True
# nb_classes가 4이면 --use_softlabel=False
# 4to2-class 계산은 --nb_classes=4에 --use_softlabel=True
# models = [
# 'results/230801_generate_image/2-class/pad_PIXEL_padsize_100.0_box_False_shift_True_sratio_1.0_tratio_1.0_nbclss_2_GAN/checkpoint-best.pth',
# 'results/230822_dataset_2/2-class/pad_PIXEL_padsize_100.0_box_False_shift_True_sratio_1.0_tratio_1.0_nbclss_2_detection/checkpoint-best.pth',
# 'results/230822_dataset_2/2-class/pad_PIXEL_padsize_100.0_box_False_shift_True_sratio_1.0_tratio_1.0_nbclss_2_except-augmentation/checkpoint-best.pth',
# 'results/230822_dataset_2/2-class/pad_PIXEL_padsize_100.0_box_False_shift_True_sratio_1.0_tratio_1.0_nbclss_2_detection+seoul_pos/checkpoint-best.pth',
# 'results/230822_dataset_2/2-class/pad_PIXEL_padsize_100.0_box_False_shift_True_sratio_1.0_tratio_1.0_nbclss_2_except-augmentation+seoul-pos/checkpoint-best.pth',
# ]
# 'results/230822_dataset_2/2-class/pad_PIXEL_padsize_100.0_box_False_shift_True_sratio_1.0_tratio_1.0_nbclss_2_except-augmentation/checkpoint-best.pth',
models = [
'results/230822_dataset_2/2-class/pad_PIXEL_padsize_100.0_box_False_shift_True_sratio_1.0_tratio_1.0_nbclss_2_except-augmentation+seoul-pos+softlabel-0.7/checkpoint-best.pth',
]
for m in models:
if not os.path.exists(m):
print(f"Check the models name {m}")
sys.exit()
# org_output_dir_path = "../res/230822_dataset_2_data/dataset_20230719"
# org_graph_save_dir = "../res/230822_dataset_2_graph/dataset_20230719"
org_output_dir_path = "../res/230822_dataset_2_data/dataset_20230713_conf-97"
org_graph_save_dir = "../res/230822_dataset_2_graph/dataset_20230713_conf-97"
for ckpt in models:
nb_cls = 0
name = ckpt.split('/')[-2]+ '_'
ops = Path(ckpt).parts[-2]
opsdict = dict(zip([str(d) for i,d in enumerate(str(ops).split('_')) if i%2==0],
[str(d) for i, d in enumerate(ops.split('_')) if i%2==1]))
output_dir_path = org_output_dir_path
graph_save_dir = org_graph_save_dir
if "nbclss_2" in ckpt:
nb_cls = 2
output_dir_path = os.path.join(output_dir_path, '2-class')
graph_save_dir = os.path.join(graph_save_dir, '2-class')
elif "nbclss_4" in ckpt and '--use_softlabel True' in base:
nb_cls = 4
output_dir_path = os.path.join(output_dir_path, '4to2-class')
graph_save_dir = os.path.join(graph_save_dir, '4to2-class')
elif "nbclss_4" in ckpt and '--use_softlabel False' in base:
nb_cls = 4
output_dir_path = os.path.join(output_dir_path, '4-class')
graph_save_dir = os.path.join(graph_save_dir, '4-class')
# if "checkpoint-valid_min_loss.pth" in ckpt:
# output_dir_path = os.path.join(output_dir_path, 'loss_model')
# graph_save_dir = os.path.join(graph_save_dir, 'loss_model')
# elif "checkpoint-best.pth" in ckpt:
# output_dir_path = os.path.join(output_dir_path, 'best_model')
# graph_save_dir = os.path.join(graph_save_dir, 'best_model')
if not os.path.exists(output_dir_path):
os.makedirs(Path(output_dir_path), exist_ok=True)
if not os.path.exists(graph_save_dir):
os.makedirs(Path(graph_save_dir), exist_ok=True)
print(output_dir_path, graph_save_dir)
os.system(f"""{base} \
--resume {ckpt} \
--padding {opsdict['pad']} \
--padding_size {opsdict['padsize']} \
--use_bbox {opsdict['box']} \
--pred_eval_name {graph_save_dir}/{name} \
--pred_save_path {output_dir_path}/{name} \
--nb_classes {nb_cls} \
--use_shift {opsdict['shift']}""")