# LB 15th (0.9970) Some new ideas (and a bug!) Our solution has two stages that can be run recursively (but we only ran then once b/c of lack of time) => 1. Predict a coarse mask (CO) . For this we used a regular UNET @ full resolution. 2. Refine the mask using patches around the mask contour ![Patchesnet](http://s3.eu-central-1.amazonaws.com/kaggle-carvana-team73/patches-net.png) This second network is a residual UNET ( [assets/b5eaa2ee0f57ec9d0cb797ac.pdf](assets/b5eaa2ee0f57ec9d0cb797ac.pdf) ) that works with patches, we used 384x384 patches. The input of the network is 384x384x6 => RGB ( 3 ) + X ( 2 ) + CO ( 1 ) Where X is the L2 difference of the patch RGB vs. a computed background. For each car, using its coarse mask we (offline) computed the background using the 16 views and basic pixel statistics: ![Computed background](http://s3.eu-central-1.amazonaws.com/kaggle-carvana-team73/carvana-background.png) When feeding the L2 difference, pixels in magenta will be substituted by gaussian noise with same mean/variance that non-magenta pixels, that's the first channel of X, the second channel is just an 1,0 mask of whether the pixel is magenta or not. Finally CO is just the probabilities (saved as PNG files) of the coarse mask for the previous iteration. We computed the effective receptive field of our residual Unet and was ~224 px. Since patches are going to overlap on inference we weighted each pixel in the patch so center pixels contributed more than edge pixels (ratio 1:4). For augmentation we just used random horizontal flips, both for training and TTA. BUG Unfortunately we had a bug and some predictions came out like this: ![Bad prediction](http://s3.eu-central-1.amazonaws.com/kaggle-carvana-team73/bad-prediction.png) Which is due (we think!) to a race condition in our Keras inference/generator pipeline... and meant we had to blindly reject predictions whose refined mask was different (dice <0.999) than the coarse one... neglecting scenarios where the refined one made a lot of corrections.