d = pd.read_csv('../data/radiopaedia_cases.csv')
dls = ImageDataLoaders3D.from_df(d,
fn_col = 0,
label_col = 2, # in sample data 0: series, 1: segmentation mask, 2: random binary label
#item_tfms = ResizeCrop3D(crop_by = (0., 0.1, 0.1), resize_to = (20, 150, 150), perc_crop = True),
size_for_resampling = (112, 112, 20),
bs = 2,
val_bs = 2,
num_workers = 0,
)
from torchvision.models.video import r3d_18
learn = cnn_learner_3d(dls, r3d_18, pretrained=False) # pretrained turned off for more speed while testing, default would be to load a pretrained model
learn.fine_tune(1, 0.001)
dls = SegmentationDataLoaders3D.from_df(d,
codes = ['no covid', 'covid'],
item_tfms = ResizeCrop3D(crop_by = (0., 0.1, 0.1), resize_to = (20, 100, 100), perc_crop = True),
bs = 2, val_bs = 2)
learn = unet_learner_3d(dls, r3d_18, pretrained=False)
learn.fit_one_cycle(1, 0.001)
dls = SegmentationDataLoaders3D.from_df(d,
codes = ['no covid', 'covid'],
item_tfms = ResizeCrop3D(crop_by = (0., 0.1, 0.1), resize_to = (20, 100, 100), perc_crop = True),
bs = 2, val_bs = 2)
learn = deeplab_learner_3d(dls, r3d_18, pretrained=False)
learn.fit_one_cycle(1, 0.001)