Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design2
/
2016104167
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
조현아
2020-03-30 17:38:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
165bb19a52dabf0c25a955d5fcf970ed3856fda4
165bb19a
1 parent
6194ff3e
FAA getBraTS_2
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
8 deletions
code/FAA2/utils.py
code/fast-autoaugment-master/FastAutoAugment/data.py
code/fast-autoaugment-master/FastAutoAugment/search.py
code/fast-autoaugment-master/FastAutoAugment/train.py
code/flair2seg_all.m
code/getframe.m
code/FAA2/utils.py
View file @
165bb19
...
...
@@ -5,6 +5,7 @@ import collections
import
pickle
as
cp
import
glob
import
numpy
as
np
import
pandas
as
pd
import
torch
import
torchvision
...
...
@@ -31,7 +32,7 @@ current_epoch = 0
def
split_dataset
(
args
,
dataset
,
k
):
# load dataset
X
=
list
(
range
(
len
(
dataset
)))
Y
=
dataset
.
targets
Y
=
dataset
# split to k-fold
assert
len
(
X
)
==
len
(
Y
)
...
...
@@ -162,9 +163,11 @@ class CustomDataset(Dataset):
return
self
.
len
def
__getitem__
(
self
,
idx
):
if
self
.
transforms
is
not
None
:
img
=
self
.
transforms
(
img
)
return
img
img
,
targets
=
self
.
img
[
idx
],
self
.
targets
[
idx
]
if
self
.
transform
is
not
None
:
img
=
self
.
transform
(
img
)
return
img
,
targets
def
get_dataset
(
args
,
transform
,
split
=
'train'
):
assert
split
in
[
'train'
,
'val'
,
'test'
,
'trainval'
]
...
...
code/fast-autoaugment-master/FastAutoAugment/data.py
View file @
165bb19
...
...
@@ -15,6 +15,9 @@ from torchvision.transforms import transforms
from
sklearn.model_selection
import
StratifiedShuffleSplit
from
theconf
import
Config
as
C
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
)))
from
FastAutoAugment.archive
import
arsaug_policy
,
autoaug_policy
,
autoaug_paper_cifar10
,
fa_reduced_cifar10
,
fa_reduced_svhn
,
fa_resnet50_rimagenet
from
FastAutoAugment.augmentations
import
*
from
FastAutoAugment.common
import
get_logger
...
...
@@ -79,6 +82,29 @@ def get_dataloaders(dataset, batch, dataroot, split=0.15, split_idx=0, multinode
transforms
.
Normalize
(
mean
=
[
0.485
,
0.456
,
0.406
],
std
=
[
0.229
,
0.224
,
0.225
])
])
elif
'BraTS'
in
dataset
:
input_size
=
240
sized_size
=
256
if
'efficientnet'
in
C
.
get
()[
'model'
][
'type'
]:
input_size
=
EfficientNet
.
get_image_size
(
C
.
get
()[
'model'
][
'type'
])
sized_size
=
input_size
+
16
# TODO
logger
.
info
(
'size changed to
%
d/
%
d.'
%
(
input_size
,
sized_size
))
transform_train
=
transforms
.
Compose
([
EfficientNetRandomCrop
(
input_size
),
transforms
.
Resize
((
input_size
,
input_size
),
interpolation
=
Image
.
BICUBIC
),
transforms
.
RandomHorizontalFlip
(),
transforms
.
ToTensor
(),
])
transform_test
=
transforms
.
Compose
([
EfficientNetCenterCrop
(
input_size
),
transforms
.
Resize
((
input_size
,
input_size
),
interpolation
=
Image
.
BICUBIC
),
transforms
.
ToTensor
(),
])
else
:
raise
ValueError
(
'dataset=
%
s'
%
dataset
)
...
...
@@ -111,7 +137,10 @@ def get_dataloaders(dataset, batch, dataroot, split=0.15, split_idx=0, multinode
if
C
.
get
()[
'cutout'
]
>
0
:
transform_train
.
transforms
.
append
(
CutoutDefault
(
C
.
get
()[
'cutout'
]))
if
dataset
==
'cifar10'
:
if
dataset
==
'BraTS'
:
total_trainset
=
testset
=
elif
dataset
==
'cifar10'
:
total_trainset
=
torchvision
.
datasets
.
CIFAR10
(
root
=
dataroot
,
train
=
True
,
download
=
True
,
transform
=
transform_train
)
testset
=
torchvision
.
datasets
.
CIFAR10
(
root
=
dataroot
,
train
=
False
,
download
=
True
,
transform
=
transform_test
)
elif
dataset
==
'reduced_cifar10'
:
...
...
code/fast-autoaugment-master/FastAutoAugment/search.py
View file @
165bb19
...
...
@@ -16,6 +16,9 @@ from ray.tune.suggest import HyperOptSearch
from
ray.tune
import
register_trainable
,
run_experiments
from
tqdm
import
tqdm
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
)))
from
FastAutoAugment.archive
import
remove_deplicates
,
policy_decoder
from
FastAutoAugment.augmentations
import
augment_list
from
FastAutoAugment.common
import
get_logger
,
add_filehandler
...
...
code/fast-autoaugment-master/FastAutoAugment/train.py
View file @
165bb19
...
...
@@ -19,6 +19,9 @@ import torch.distributed as dist
from
tqdm
import
tqdm
from
theconf
import
Config
as
C
,
ConfigArgumentParser
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
)))
from
FastAutoAugment.common
import
get_logger
,
EMA
,
add_filehandler
from
FastAutoAugment.data
import
get_dataloaders
from
FastAutoAugment.lr_scheduler
import
adjust_learning_rate_resnet
...
...
code/flair2seg_all.m
View file @
165bb19
...
...
@@ -32,6 +32,7 @@ for i = 1 : length(subFolders)
% copy flair, segment flair data
% seg의 검은 부분(정보 x)과 같은 인덱스 = 0
cp_flair
(
seg
==
0
)
=
0
;
% save a segmented data
...
...
code/getframe.m
View file @
165bb19
inputheader
=
'..\data\MICCAI_BraTS_2019_Data_Training\HGG_seg_flair\'
;
outfolder
=
'..\data\MICCAI_BraTS_2019_Data_Training\frame\'
;
outfolder
=
'..\data\MICCAI_BraTS_2019_Data_Training\
total_
frame\'
;
files
=
dir
(
inputheader
);
id
=
{
files
.
name
};
...
...
@@ -38,14 +38,14 @@ for i = 1 : length(files)
c
=
0
;
step
=
round
(((
en
)
-
(
st
))/
11
);
for
k
=
st
+
step
:
step
:
st
+
step
*
10
c
=
c
+
1
;
type
=
'.png'
;
filename
=
strcat
(
id
,
'_'
,
int2str
(
c
),
type
);
% BraTS19_2013_2_1_seg_flair_c.png
outpath
=
strcat
(
outfolder
,
filename
);
% typecase int16 to double, range[0, 1], rotate 90 and filp updown
cp_data
=
flipud
(
rot90
(
mat2gray
(
double
(
data
(:,:,
k
)))));
imwrite
(
cp_data
,
outpath
);
c
=
c
+
1
;
end
end
...
...
Please
register
or
login
to post a comment