{"cells":[{"metadata":{"trusted":true},"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport matplotlib.image as mpimg","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"import pandas as pd\nimport numpy as np\n\ndf = pd.read_csv('/kaggle/input/imaterialist-fashion-2020-fgvc7/train.csv')","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"image_df = df.groupby('ImageId')['AttributesIds', 'ClassId'].agg(lambda x: list(x))\nimage_df.reset_index(inplace=True)\nimage_df['ImageId'] = image_df['ImageId'].astype('str')\nprint(image_df.head())\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"names = [\"shirt, blouse\",\"top, t-shirt, sweatshirt\",\"sweater\",\"cardigan\",\n\"jacket\",\"vest\",\"pants\",\"shorts\",\"skirt\",\"coat\",\"dress\",\"jumpsuit\",\"cape\",\n\"glasses\",\"hat\",\"headband, head covering, hair accessory\",\"tie\",\"glove\",\n\"watch\",\"belt\",\"leg warmer\",\"tights, stockings\",\"sock\",\"shoe\",\"bag, wallet\",\n\"scarf\",\"umbrella\",\"hood\",\"collar\",\"lapel\",\"epaulette\",\"sleeve\",\"pocket\",\"neckline\",\n\"buckle\",\"zipper\",\"applique\",\"bead\",\"bow\",\"flower\",\"fringe\",\"ribbon\",\"rivet\",\"ruffle\",\n\"sequin\",\"tassel\"]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"set_cls= []\nfor i in range(len(image_df)):\n    classes = list(set(image_df['ClassId'].iloc[i]))\n    set_cls.append(classes)\n    \nimage_df['SetClassId'] = set_cls\nimage_df.drop(['AttributesIds','ClassId'],axis=1,inplace=True)\n\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"image_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"for i in range(25):\n    x = np.random.randint(0,len(image_df),size=(1,))[0]\n    ID = image_df['ImageId'].iloc[x]\n    classes = image_df['SetClassId'].iloc[x]\n    print('*'*50)\n    plt.imshow(mpimg.imread(f'/kaggle/input/imaterialist-fashion-2020-fgvc7/train/{ID}.jpg'))\n    plt.show()\n    for j in range(len(classes)):\n        print('[{}] {} '.format(j,names[classes[j]]))\n    print('*'*50)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"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}