{"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_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nfrom tqdm.notebook import tqdm\nimport os\nfrom termcolor import colored\nimport plotly.express as px\nimport matplotlib.pyplot as plt\nimport cv2","metadata":{"execution":{"iopub.status.busy":"2021-10-27T19:03:48.832985Z","iopub.execute_input":"2021-10-27T19:03:48.833317Z","iopub.status.idle":"2021-10-27T19:03:49.026263Z","shell.execute_reply.started":"2021-10-27T19:03:48.833275Z","shell.execute_reply":"2021-10-27T19:03:49.025617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"DIRECTORY_PATH = \"../input/sartorius-cell-instance-segmentation\"\nTRAIN_CSV = DIRECTORY_PATH + \"/train.csv\"\nTRAIN_PATH = DIRECTORY_PATH + \"/train\"\nTEST_PATH = DIRECTORY_PATH + \"/test\"\nTRAIN_SEMI_SUPERVISED_PATH = DIRECTORY_PATH + \"/train_semi_supervised\"","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:55:18.767653Z","iopub.execute_input":"2021-10-27T18:55:18.768465Z","iopub.status.idle":"2021-10-27T18:55:18.773276Z","shell.execute_reply.started":"2021-10-27T18:55:18.768382Z","shell.execute_reply":"2021-10-27T18:55:18.772473Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def get_Image_paths(path):\n    \"\"\"\n    Function to get the path with individual image Paths\n    \"\"\"\n    image_names= []\n    for dirname,_,filenames in os.walk(path):\n        for filename in tqdm(filenames):\n            fullpath =os.path.join(dirname,filename)\n            image_names.append(fullpath)\n    return image_names\n    ","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:55:19.101042Z","iopub.execute_input":"2021-10-27T18:55:19.101773Z","iopub.status.idle":"2021-10-27T18:55:19.106380Z","shell.execute_reply.started":"2021-10-27T18:55:19.101726Z","shell.execute_reply":"2021-10-27T18:55:19.105755Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train=pd.read_csv(TRAIN_CSV)\n#Get complete image paths for train and test datasets\ntrain_images_path = get_Image_paths(TRAIN_PATH)\ntest_images_path = get_Image_paths(TEST_PATH)\ntrain_semi_supervised_path = get_Image_paths(TRAIN_SEMI_SUPERVISED_PATH)","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:55:21.958888Z","iopub.execute_input":"2021-10-27T18:55:21.959384Z","iopub.status.idle":"2021-10-27T18:55:22.840364Z","shell.execute_reply.started":"2021-10-27T18:55:21.959332Z","shell.execute_reply":"2021-10-27T18:55:22.839763Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.head()","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:55:46.719901Z","iopub.execute_input":"2021-10-27T18:55:46.720414Z","iopub.status.idle":"2021-10-27T18:55:46.741156Z","shell.execute_reply.started":"2021-10-27T18:55:46.720375Z","shell.execute_reply":"2021-10-27T18:55:46.740555Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.info()","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:56:10.347988Z","iopub.execute_input":"2021-10-27T18:56:10.348455Z","iopub.status.idle":"2021-10-27T18:56:10.401137Z","shell.execute_reply.started":"2021-10-27T18:56:10.348414Z","shell.execute_reply":"2021-10-27T18:56:10.400321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Size of dataset\ndf_train.shape","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:56:47.183305Z","iopub.execute_input":"2021-10-27T18:56:47.184057Z","iopub.status.idle":"2021-10-27T18:56:47.188076Z","shell.execute_reply.started":"2021-10-27T18:56:47.184019Z","shell.execute_reply":"2021-10-27T18:56:47.187457Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Columnwise unique values\nfor col in df_train.columns:\n    print(col + \":\" + colored(str(len(df_train[col].unique())), 'blue'))\n    ","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:58:24.155325Z","iopub.execute_input":"2021-10-27T18:58:24.155631Z","iopub.status.idle":"2021-10-27T18:58:24.251177Z","shell.execute_reply.started":"2021-10-27T18:58:24.155597Z","shell.execute_reply":"2021-10-27T18:58:24.250315Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Number of Images in Each Directory\nprint(f\"Number of train images: {colored(len(train_images_path), 'blue')}\")\nprint(f\"Number of test images:  {colored(len(test_images_path), 'blue')}\")","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:59:02.882472Z","iopub.execute_input":"2021-10-27T18:59:02.882915Z","iopub.status.idle":"2021-10-27T18:59:02.888192Z","shell.execute_reply.started":"2021-10-27T18:59:02.882878Z","shell.execute_reply":"2021-10-27T18:59:02.887029Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_distribution(x):\n\n    fig = px.histogram(\n    df_train, \n    x = x,\n    width = 800,\n    height = 500,\n    )\n    \n    fig.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-27T18:59:49.552390Z","iopub.execute_input":"2021-10-27T18:59:49.553074Z","iopub.status.idle":"2021-10-27T18:59:49.558147Z","shell.execute_reply.started":"2021-10-27T18:59:49.553012Z","shell.execute_reply":"2021-10-27T18:59:49.557370Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_distribution('cell_type')","metadata":{"execution":{"iopub.status.busy":"2021-10-27T19:00:14.416012Z","iopub.execute_input":"2021-10-27T19:00:14.416808Z","iopub.status.idle":"2021-10-27T19:00:14.843101Z","shell.execute_reply.started":"2021-10-27T19:00:14.416767Z","shell.execute_reply":"2021-10-27T19:00:14.842290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_distribution('plate_time')","metadata":{"execution":{"iopub.status.busy":"2021-10-27T19:00:18.675706Z","iopub.execute_input":"2021-10-27T19:00:18.676548Z","iopub.status.idle":"2021-10-27T19:00:19.268106Z","shell.execute_reply.started":"2021-10-27T19:00:18.676513Z","shell.execute_reply":"2021-10-27T19:00:19.267293Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_distribution('elapsed_timedelta')","metadata":{"execution":{"iopub.status.busy":"2021-10-27T19:00:29.792898Z","iopub.execute_input":"2021-10-27T19:00:29.793209Z","iopub.status.idle":"2021-10-27T19:00:30.400550Z","shell.execute_reply.started":"2021-10-27T19:00:29.793173Z","shell.execute_reply":"2021-10-27T19:00:30.399654Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def display_multiple_img(images_paths, rows, cols):\n    \"\"\"\n    Function to Display Images from Dataset.\n    \n    parameters: images_path(string) - Paths of Images to be displayed\n                rows(int) - No. of Rows in Output\n                cols(int) - No. of Columns in Output\n    \"\"\"\n    figure, ax = plt.subplots(nrows=rows,ncols=cols,figsize=(16,8) )\n    for ind,image_path in enumerate(images_paths):\n        image=cv2.imread(image_path)\n        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) \n        try:\n            ax.ravel()[ind].imshow(image)\n            ax.ravel()[ind].set_axis_off()\n        except:\n            continue;\n    plt.tight_layout()\n    plt.show()","metadata":{"execution":{"iopub.status.busy":"2021-10-27T19:09:15.281781Z","iopub.execute_input":"2021-10-27T19:09:15.282067Z","iopub.status.idle":"2021-10-27T19:09:15.289081Z","shell.execute_reply.started":"2021-10-27T19:09:15.282039Z","shell.execute_reply":"2021-10-27T19:09:15.288086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_multiple_img(train_images_path[100:150], 3, 3)","metadata":{"execution":{"iopub.status.busy":"2021-10-27T19:09:54.452660Z","iopub.execute_input":"2021-10-27T19:09:54.453329Z","iopub.status.idle":"2021-10-27T19:09:56.323030Z","shell.execute_reply.started":"2021-10-27T19:09:54.453286Z","shell.execute_reply":"2021-10-27T19:09:56.321887Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"display_multiple_img(test_images_path, 1, 3)","metadata":{"execution":{"iopub.status.busy":"2021-10-27T19:09:42.266113Z","iopub.execute_input":"2021-10-27T19:09:42.267035Z","iopub.status.idle":"2021-10-27T19:09:42.796130Z","shell.execute_reply.started":"2021-10-27T19:09:42.266988Z","shell.execute_reply":"2021-10-27T19:09:42.795019Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}