Kaggle competition: TGS Salt Identification Challenge
<SOS> metric: IntersectionOverUnionObjectSegmentation Kaggle data source: tgs-salt-identification-challenge<choose_model_class>
%matplotlib inline
my_new_model.compile(optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
<init_hyperparams>
def rle_decode(rle_mask):

 s = rle_mask.split()
starts, lengths = [np.asarray(x, dtype=int)for x in(s[0:][::2], s[1:][::2])]
starts -= 1
ends = starts + lengths
img = np.zeros(101*101, dtype=np.uint8)
 for lo, hi in zip(starts, ends):
img[lo:hi] = 1
return img.reshape(101,101 )
image_size = 299
datagen = ImageDataGenerator(preprocessing_function=preprocess_input,
rescale=1./255.,
horizontal_flip=True,
width_shift_range = 0.2,
height_shift_range = 0.2,
validation_split=0.25 )<create_dataframe>

 df = pd.read_csv('.. /input/submit-802/test_18000-null.csv')
 i = 0
j = 0
plt.figure(figsize=(30,15))
plt.subplots_adjust(bottom=0.2, top=0.8, hspace=0.2)
 while True:
if str(df.loc[i,'rle_mask'])!=str(np.nan):
decoded_mask = rle_decode(df.loc[i,'rle_mask'])
 plt.subplot(1,6,j+1)
 plt.imshow(decoded_mask)
 plt.title('ID: '+df.loc[i,'id'])
 j = j + 1
if j>5:
break
i = i + 1
train_generator=datagen.flow_from_dataframe(
 dataframe=traindf,
directory=".. /input/dog-breed-identification/train/",
x_col="id",
y_col="breed",
has_ext=False,
subset="training",
batch_size=32,
seed=42,
shuffle=True,
class_mode="categorical",
target_size=(image_size, image_size))<create_dataframe>
test_path = '.. /input/tgs-salt-identification-challenge/test/images/'
valid_generator=datagen.flow_from_dataframe(
 dataframe=traindf,
directory=".. /input/dog-breed-identification/train/",
x_col="id",
y_col="breed",
has_ext=False,
subset="validation",
batch_size=1,
seed=42,
shuffle=True,
class_mode="categorical",
target_size=(image_size, image_size))<create_dataframe>

 def rle_encode(im):

 pixels = im.flatten()
pixels = np.concatenate([[0], pixels, [0]])
 runs = np.where(pixels[1:] != pixels[:-1])[0] + 1
runs[1::2] -= runs[::2]
return ' '.join(str(x)for x in runs )
<train_model><EOS> 
df.to_csv('crf_correction.csv',index=False )