Skip to content

Commit

Permalink
test metaposfix for ISIC20
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxwvu321 committed Jun 9, 2020
1 parent ceb7230 commit 300d00b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@

_C.DATASETS.N_AUG = 1

_C.DATASETS.META_POS = ['anterior torso','head/neck','lower extremity','palms/soles','posterior torso','upper extremity']
# -----------------------------------------------------------------------------
# DataLoader
# -----------------------------------------------------------------------------
Expand Down
34 changes: 34 additions & 0 deletions configs/effb4_meta_default20_extrameta_w_d_metafix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
MODEL:

BACKBONE: 'effnetb4'
NAME: 'effb4_SVMeta'

IMG_FCS: [3584,512]
META_DIMS: [17,6,1,3,2]


DATASETS:
ROOT_DIR: ['../data/all18_coloradj','../data/all20_coloradj']
DICT_LABEL: ['NV', 'MEL']
INFO_CSV: ['./dat/all18_info1_convert20.csv','./dat/all20_info1.csv']
NUM_CLASS: 2
META_POS: [,'head/neck','upper extremity','lower extremity','torso','palms/soles','oral/genital']


DATALOADER:
BATCH_SIZE: 12
SAMPLER: 'weighted_meta'
NUM_WORKERS: 8
TEST:
BATCH_SIZE: 32

MISC:
OUT_DIR: "../checkpoint/effb4_meta_default20_d_metafix"
VALID_EPOCH: 10
LOG_PERIOD: 10000

INPUT:
CRP_SCALE: [0.1,1.0]
CRP_RATIO: [0.75,1.33]
SOLVER:
EPOCHS: 50
31 changes: 31 additions & 0 deletions configs/effb4_meta_default20_extrameta_w_d_metafix_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
MODEL:

BACKBONE: 'effnetb4'
NAME: 'effb4_SVMeta'

IMG_FCS: [3584,512]
META_DIMS: [17,6,1,3,2]
DATASETS:
ROOT_DIR: ['../data/all20_usp_coloradj']
DICT_LABEL: ['NV', 'MEL']
INFO_CSV: ['./dat/all20_info_usp.csv']
NUM_CLASS: 2
META_POS: [,'head/neck','upper extremity','lower extremity','torso','palms/soles','oral/genital']

DATALOADER:
BATCH_SIZE: 12
SAMPLER: 'weighted_meta'
NUM_WORKERS: 8
TEST:
BATCH_SIZE: 32

MISC:
OUT_DIR: "../checkpoint/effb4_meta_default20_d_metafix"
VALID_EPOCH: 10
LOG_PERIOD: 10000

INPUT:
CRP_SCALE: [0.1,1.0]
CRP_RATIO: [0.75,1.33]
SOLVER:
EPOCHS: 50
4 changes: 3 additions & 1 deletion data/datasets/ISIC_Dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@ def __init__(self, root, meta_list, dict_label = ['MEL', 'NV', 'BCC', 'AKIEC', '
#self.bbox_info = np.array(im_info[:,7:11]).astype('float32')

meta_feat = list()

if 'age' in meta_list:
meta_age = parse_age(im_info[:,4], th_list=np.arange(5,90,5))
meta_feat.append(meta_age)
if 'pos' in meta_list:
meta_pos = parse_pos(im_info[:,5], all_pos =['anterior torso','head/neck','lower extremity','palms/soles','posterior torso','upper extremity'])
all_pos = self.cfg.DATASETS.META_POS
meta_pos = parse_pos(im_info[:,5], all_pos =all_pos)#['anterior torso','head/neck','lower extremity','palms/soles','posterior torso','upper extremity'])
meta_feat.append(meta_pos)
if 'sex' in meta_list:
meta_sex = parse_sex(im_info[:,6])
Expand Down
12 changes: 12 additions & 0 deletions utils/parse_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,18 @@ def parse_pos(pos_list, all_pos):
# in ISIC19, there are more position ,need fix
pos_idx = all_pos.index(pos)
meta_pos[idx][pos_idx] = 1
else: # if meta info is a superset of given pos
pos_out = []
for idx,pp in enumerate(all_pos):
if pp in pos:
pos_out.append(idx)
if len(pos_out)==1:
meta_pos[idx][pos_out[0]] = 1
elif len(pos_out)==0:
pass
else:
raise ValueError('two match')

elif math.isnan(pos) is True:
pass
else:
Expand Down

0 comments on commit 300d00b

Please sign in to comment.