{"cells":[{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"import pandas as pd\ntrain_df = pd.read_csv(\"/kaggle/input/imaterialist-fashion-2020-fgvc7/train.csv\")","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# most object is small","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"from tqdm import tqdm\nareas = []\nfor index,row in tqdm(train_df.iterrows(), total = len(train_df)):\n#     sub_mask = np.full(row['Height']*row['Width'], 0, dtype=np.uint8) \n    fashion_rle = [int(x) for x in row[\"EncodedPixels\"].split(' ')]\n    area = 0\n    for j, start_pixel in enumerate(fashion_rle[::2]):\n#         sub_mask[start_pixel: start_pixel+fashion_rle[2*j+1]] = 1    \n        area = fashion_rle[2*j+1] + area\n    areas.append([area, row['ImageId'], row['Height'], row['Width'], row['ClassId'], row['AttributesIds']])\n    \nimport pickle\nwith open('./areas.pk', 'wb') as f:\n    pickle.dump(areas, f)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"rates = []\nfor area in areas:\n    rate = area[0] / (area[2]*area[3]) \n    rates.append(rate)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"areas_pd = pd.DataFrame(rates)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"areas_pd.describe(percentiles=[.25, .5, .6, .75])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"areas_pd.plot(kind = 'hist',bins = 1000, figsize = (10,10),  fontsize = 10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"areas_pd.plot(kind = 'hist',bins = 1000, figsize = (10,10), logx= True, fontsize = 10)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# Half of the pictures have sides longer than 1385 pixels","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"lengths = []\nfor area in areas:\n    length = np.sqrt((area[2]*area[3]))\n    lengths.append(length)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"lengths_pd = pd.DataFrame(lengths)\nlengths_pd.plot(kind = 'hist',bins = 30, figsize = (10,10), logx= False, fontsize = 10)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"lengths_pd.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"markdown","source":"","execution_count":null}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}