Kaggle competition: Severstal: Steel Defect Detection
predictions =(p1 + p2 + p3 + p4 + p5)/ 5
sample = pd.read_csv(".. /input/siim-isic-melanoma-classification/sample_submission.csv")
 sample.loc[:, "target"] = predictions
sample.to_csv("submission.csv", index=False )<import_modules>
warnings.filterwarnings('ignore')
import numpy as np
import pandas as pd
import os
from matplotlib import pyplot as plt<define_variables>
unet = load('.. /input/severstaleffnet/traced_effnetb7_mixup_retrain.pth' ).cuda()
cls = load('.. /input/severstall-effnetb0-fimal-stage/traced_model.pth' ).cuda()
cls_alt = load('.. /input/severstaleffnet/traced_effnetb0_lovasz.pth' ).cuda()
WEIGHT = 1<load_from_csv>
def create_transforms(additional):
res = list(additional)
 res.extend([
A.Normalize(
 mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225)
),
ChannelTranspose()
])
 res = A.Compose(res)
 return res
img_folder = '/kaggle/input/severstal-steel-defect-detection/test_images'
batch_size = 1
num_workers = 0
transforms = [
[],
[A.HorizontalFlip(p=1)],
[A.VerticalFlip(p=1)],
]
transforms = [create_transforms(t)for t in transforms]
datasets = [TtaWrap(ImageDataset(img_folder=img_folder, transforms=t), tfms=t)for t in transforms]
loaders = [DataLoader(d, num_workers=num_workers, batch_size=batch_size, shuffle=False)for d in datasets]
submission = pd.read_csv('.. /input/siim-isic-melanoma-classification/sample_submission.csv')
 test = pd.read_csv('.. /input/siim-isic-melanoma-classification/test.csv')
 sub_best = pd.read_csv('.. /input/eda-modelling-of-the-external-data-inc-ensemble/external_meta_ensembled.csv' )<define_variables>
l = torch.tensor([1, 0])
 if np.count_nonzero(l):
print('yay' )
files_sub = [
'.. /input/minmax-ensemble-0-9526-lb/submission.csv',
'.. /input/new-basline-np-log2-ensemble-top-10/submission.csv',
'.. /input/stacking-ensemble-on-my-submissions/submission_mean.csv',
'.. /input/analysis-of-melanoma-metadata-and-effnet-ensemble/ensembled.csv',
'.. /input/eda-modelling-of-the-external-data-inc-ensemble/external_meta_ensembled.csv',
'.. /input/submission-exploration/submission.csv',
'.. /input/rc-fork-siim-isic-melanoma-384x384/sub_EfficientNetB2_384.csv',
'.. /input/train-cv/submission.csv',
'.. /input/triple-stratified-kfold-with-tfrecords/submission.csv',
'.. /input/rank-then-blend/blend_sub.csv',
'.. /input/siim-isic-melanoma-classification-ensemble/submission.csv'
]
files_sub = sorted(files_sub)
 print(len(files_sub))
files_sub<feature_engineering>
df = pd.DataFrame(res)
 df = df.fillna('')
 df.to_csv('submission.csv', index=False )
for file in files_sub:
test[file.replace(".csv", "")] = pd.read_csv(file ).sort_values('image_name')["target"]
test['id'] = test.index<feature_engineering>
df['Image'] = df['ImageId_ClassId'].map(lambda x: x.split('_')[0])
 df['Class'] = df['ImageId_ClassId'].map(lambda x: x.split('_')[1])
 df['empty'] = df['EncodedPixels'].map(lambda x: not x)
 df[df['empty'] == False]['Class'].value_counts()
test["diff_good1"] = test['.. /input/rank-then-blend/blend_sub'] - test['.. /input/triple-stratified-kfold-with-tfrecords/submission']
test["diff_good1"] = test['.. /input/train-cv/submission'] - test['.. /input/siim-isic-melanoma-classification-ensemble/submission']
test["diff_good2"] = test['.. /input/rc-fork-siim-isic-melanoma-384x384/sub_EfficientNetB2_384'] - test['.. /input/submission-exploration/submission']
test["diff_good3"] = test['.. /input/analysis-of-melanoma-metadata-and-effnet-ensemble/ensembled'] - test['.. /input/new-basline-np-log2-ensemble-top-10/submission']
test["diff_bad1"] = test['.. /input/stacking-ensemble-on-my-submissions/submission_mean'] - test['.. /input/minmax-ensemble-0-9526-lb/submission']<feature_engineering>
%matplotlib inline
df = pd.read_csv('submission.csv')[:40]
df['Image'] = df['ImageId_ClassId'].map(lambda x: x.split('_')[0])
 df['Class'] = df['ImageId_ClassId'].map(lambda x: x.split('_')[1])
 for row in df.itertuples() :
img_path = os.path.join(img_folder, row.Image)
 img = cv2.imread(img_path)
 mask = rle2mask(row.EncodedPixels,(1600, 256)) \
if isinstance(row.EncodedPixels, str)else np.zeros(( 256, 1600))
if mask.sum() == 0:
continue
fig, axes = plt.subplots(1, 2, figsize=(20, 60))
axes[0].imshow(img/255)
 axes[1].imshow(mask*60)
 axes[0].set_title(row.Image)
 axes[1].set_title(row.Class)
 plt.show()