Kaggle competition: APTOS 2019 Blindness Detection
<SOS> metric: QuadraticWeightedKappa Kaggle data source: aptos-2019-blindness-detection<create_dataframe>
%reload_ext autoreload
%autoreload 2
%matplotlib inline
warnings.filterwarnings("ignore")
 %matplotlib inline
train_dataset = get_training_dataset()
valid_dataset = get_validation_dataset()<train_model>
md_ef = EfficientNet.from_pretrained('efficientnet-b5', num_classes=1)
 !mkdir models
!cp '.. /input/kaggle-public/abcdef.pth' 'models'
if TRAINING:
history = model.fit(
 train_dataset,
epochs=EPOCHS,
callbacks=[lr_schedule],
steps_per_epoch=STEPS_PER_EPOCH,
validation_data=valid_dataset 
)
 model.save("efficientnetb7.h5" )<train_model>
bs = 64
tfms = get_transforms(do_flip=True,flip_vert=True )
if TRAINING:
history2 = model2.fit(
 train_dataset,
epochs=EPOCHS,
callbacks=[lr_schedule],
steps_per_epoch=STEPS_PER_EPOCH,
validation_data=valid_dataset 
)
 model2.save("efficientnetb0.h5" )<prepare_output>
learn.load('abcdef');
opt = OptimizedRounder()
sub1 = sub.copy()
sub2 = sub.copy()<predict_on_test>
preds0,y = learn.get_preds(DatasetType.Test )
if TRAINING:
test_ds = get_test_dataset(ordered=True)
 print('Computing predictions...')
 test_images_ds = test_ds.map(lambda image, idnum: image)
 probabilities = model.predict(test_images_ds)
 probabilities2 = model2.predict(test_images_ds)
 print('Generating submission.csv file...')
 test_ids_ds = test_ds.map(lambda image, idnum: idnum ).unbatch()
test_ids = next(iter(test_ids_ds.batch(NUM_TEST_IMAGES)) ).numpy().astype('U' )<save_to_csv>
preds =(preds0 + preds1 + preds2 + preds3 + preds4)/5
<save_to_csv><EOS> 
tst_pred = opt.predict(preds, coef=[0.5, 1.5, 2.5, 3.5])
 test_df.diagnosis = tst_pred.astype(int)
 test_df.to_csv('submission.csv',index=False)
 print('done' )