{"cells":[{"metadata":{},"cell_type":"markdown","source":"The prediction has two stages.\n\n1. First we predict the correct class of image. \n1. Next we predict the correct class attribute of the image.\n\n"},{"metadata":{},"cell_type":"markdown","source":"# Predict the correct class of image.\n\nThe encoded pixels have overlapping class information. We are creating only one label for a image. The overlapping class information is lost.(Here I deviate from problem statement.)\nWe train our model using resnet34. First on 224 \\* 224 image. Then 512 \\* 512 images.\n\nThis model can predict the class of pixel.\nBut we still need to predict the attribute for correct submission.\n"},{"metadata":{},"cell_type":"markdown","source":"**Train & predict class with 224 * 224 images.**\n\nhttps://www.kaggle.com/nikhilikhar/fastai-imaterialist-224?scriptVersionId=15267678"},{"metadata":{},"cell_type":"markdown","source":"**Train & predict class with 512 * 512 images.**\n\nhttps://www.kaggle.com/nikhilikhar/fastai-imaterialist-512?scriptVersionId=15344715\n\n![](https://www.kaggleusercontent.com/kf/15344715/eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..Qm6QeHm4GjTmzga9issP0g.TpI_j_vg40mH4oe__0RcultxIEoZU_kp7FLXBii_pbTVVnPrn9TazDNcjOp9xevBa8t54tNKWGf9kV2nb6dH5KPoWb6ujLMFRTkHXI7kyEZr6NfjQa3ngWXYT1-l-5J4bp__XpApK6kwXsEx4eoubw.zwCrE1BYd85ba4HHXjlwJw/__results___files/__results___19_0.png)"},{"metadata":{},"cell_type":"markdown","source":"# Predict the correct class attribute of the image.\n\nFrom above 512 * 512 model we predict the correct class. Each test image has one or more class. \nThe result is stored in form of dataframe.\n\nFrom the model we create a multi-label trainig data. Each image is showing all predicted classes. (Here I deviate from problem statement.)\n\nWe will train on this newly created data to find the correct attribute inside the images.\n\nBG => no attribute\n\n![Sample Predicted labels](https://www.kaggleusercontent.com/kf/15346189/eyJhbGciOiJkaXIiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..YG6sba3Jcmj9dvH87k8CtA.RvtOcdQGxT_GnWZ8a3uQloiAsjxTxWFosm1uyYwfbyesrTURZuH852JZh44ztftB1U60apeqJReE0et6iv-9JoQSJMBVXKn0iPybpuK3aW0tDOJWWCBqccT0rD4xtEMBHvOV9-uyDKfqiARMWJiA4ONVh39bl8n77lyRGMwec8Drl1MnM4rrNv9BkCGfETh9.gftdDrmyaQS4zwO3GvLHQA/__results___files/__results___10_0.png)"},{"metadata":{},"cell_type":"markdown","source":"**Train model for multi class label classification**\n\nhttps://www.kaggle.com/nikhilikhar/fastai-imaterialist-multilabel-classification?scriptVersionId=15346189\n\nThis kernel was developed on small set of data. \n\nI wanted to train with more images and I met some of Kaggle kernel limitations (See below).\n\nNon working kernel -> https://www.kaggle.com/nikhilikhar/fastai-imaterialist-multilabel-classification?scriptVersionId=15368548"},{"metadata":{},"cell_type":"markdown","source":"**Class and attribute prediction**\n\nWe use multiclass label classification model to predict the correct attribute. (Incomplete because above is working due to kaggle limitations.)\n\nhttps://www.kaggle.com/nikhilikhar/fastai-imaterialist-multilabel-segmentation?scriptVersionId=15404255\n"},{"metadata":{},"cell_type":"markdown","source":"# Kaggle Kernel Limitations\n\n* Kaggle kernel can run for max 9 hrs.\n* Kaggle kernel has memory limit of [17179869184 byte approx 17Gb](https://www.kaggle.com/nikhilikhar/fastai-imaterialist-multi-label-data/log?scriptVersionId=15401077). Program will exit with code 137. I m not sure why I hit this limit. I was no where near this limit.\n* Kaggle kernel doesn't support more than 500 output file. This happen when I tired to [create test label separetly](https://www.kaggle.com/nikhilikhar/fastai-imaterialist-multi-label-data/log?scriptVersionId=15397908) to avoid memory limit.\n* Kaggle was not able to create a new process when using `preds,y = learn.get_preds(ds_type=DatasetType.Test)`. And it was giving [memory error](https://www.kaggle.com/nikhilikhar/fastai-imaterialist-multilabel-segmentation?scriptVersionId=15371701#L210).\n\n"},{"metadata":{},"cell_type":"markdown","source":"# Kaggle resources\nI found these kernels useful in developing the solution.\n\n* https://www.kaggle.com/pednoi/training-mask-r-cnn-to-be-a-fashionista-lb-0-07\n* https://www.kaggle.com/go1dfish/u-net-baseline-by-pytorch-in-fgvc6-resize\n* https://www.kaggle.com/solpaul/fastai-factory-approach-using-mask-images"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}