Kaggle competition: APTOS 2019 Blindness Detection
<SOS> metric: QuadraticWeightedKappa Kaggle data source: aptos-2019-blindness-detection<define_variables>
sys.path.append(os.path.abspath('.. /input/efficientnet/efficientnet-master/efficientnet-master/'))
def create_effnetB5_model(input_shape, n_out):
model = Sequential()
base_model = EfficientNetB5(weights = None,
include_top = False,
input_shape = input_shape)
 base_model.name = 'base_model'
model.add(base_model)
 model.add(Dropout(0.25))
model.add(Dense(1024))
model.add(LeakyReLU())
 model.add(GlobalAveragePooling2D())
 model.add(Dropout(0.5))
model.add(Dense(n_out, activation = 'sigmoid'))
return model
target = 'target'
predictors = train_df.columns.values.tolist() [2:]<count_values>
PRETRAINED_MODEL = '.. /input/efficientnetb5-blindness-detector/blindness_detector_best_qwk.h5'
IMAGE_HEIGHT = 340
IMAGE_WIDTH = 340
num_classes = 5
class_text = ['Normal', 'Mild', 'Moderate', 'Severe', 'Proliferative']
print('Creating model...')
 model = create_effnetB5_model(input_shape =(IMAGE_HEIGHT, IMAGE_WIDTH, 3), n_out = num_classes)
 print('Restoring model from ' + PRETRAINED_MODEL + '...')
 model.load_weights(PRETRAINED_MODEL)
 model.summary()
train_df.target.value_counts()<normalization>
submit = pd.read_csv('.. /input/aptos2019-blindness-detection/sample_submission.csv')
 predicted = []
print("Making predictions...")
 for i, name in tqdm(enumerate(submit['id_code'])) :
path = os.path.join('.. /input/aptos2019-blindness-detection/test_images/', name + '.png')
 image = cv2.imread(path)
 image = process_image(image)
 X = np.array(( image[np.newaxis])/ 255)
 raw_prediction = model.predict(X)> 0.5
prediction = raw_prediction.astype(int ).sum(axis = 1)- 1
predicted.append(prediction[0] )
<choose_model_class><EOS> 
submit['diagnosis'] = predicted
submit.to_csv('submission.csv', index = False)
 submit.head(10 )