{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nimport matplotlib.pyplot as plt\n%matplotlib inline\nfrom PIL import Image\nfrom glob import glob\nimport cv2\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-19T21:20:26.827966Z","iopub.execute_input":"2022-03-19T21:20:26.828289Z","iopub.status.idle":"2022-03-19T21:20:59.607495Z","shell.execute_reply.started":"2022-03-19T21:20:26.828246Z","shell.execute_reply":"2022-03-19T21:20:59.606559Z"},"_kg_hide-input":true,"_kg_hide-output":true,"collapsed":true,"jupyter":{"outputs_hidden":true},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"![](https://camo.githubusercontent.com/6b05e8e2a501ee8d1a6806a0613d4b7b122a6fb36775469ac1d3bda6ae99e797/687474703a2f2f696d672e796f75747562652e636f6d2f76692f4f4f54335549585a7a74452f302e6a7067)github.com","metadata":{}},{"cell_type":"code","source":"import keras\nfrom keras.preprocessing.image import ImageDataGenerator\nfrom keras.applications.vgg16 import VGG16\nfrom keras.applications.vgg16 import preprocess_input\nfrom keras import Model, layers\nfrom keras.callbacks import *\nfrom keras.models import load_model, model_from_json","metadata":{"execution":{"iopub.status.busy":"2022-03-19T21:20:59.608818Z","iopub.execute_input":"2022-03-19T21:20:59.60907Z","iopub.status.idle":"2022-03-19T21:20:59.614515Z","shell.execute_reply.started":"2022-03-19T21:20:59.60904Z","shell.execute_reply":"2022-03-19T21:20:59.613365Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plotImages(artist,directory):\n    print(artist)\n    multipleImages = glob(directory)\n    plt.rcParams['figure.figsize'] = (15, 15)\n    plt.subplots_adjust(wspace=0, hspace=0)\n    i_ = 0\n    for l in multipleImages[:25]:\n        im = cv2.imread(l)\n        im = cv2.resize(im, (128, 128)) \n        plt.subplot(5, 5, i_+1) #.set_title(l)\n        plt.imshow(cv2.cvtColor(im, cv2.COLOR_BGR2RGB)); plt.axis('off')\n        i_ += 1\n        \n        \nplotImages(\"Hotel Masks in Gray Scale\",\"../input/hotel-id-to-combat-human-trafficking-2022-fgvc9/train_masks/**\")","metadata":{"execution":{"iopub.status.busy":"2022-03-19T21:26:18.040017Z","iopub.execute_input":"2022-03-19T21:26:18.040353Z","iopub.status.idle":"2022-03-19T21:26:21.16052Z","shell.execute_reply.started":"2022-03-19T21:26:18.040319Z","shell.execute_reply":"2022-03-19T21:26:21.159669Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plotImages(artist,directory):\n    print(artist)\n    multipleImages = glob(directory)\n    plt.rcParams['figure.figsize'] = (15, 15)\n    plt.subplots_adjust(wspace=0, hspace=0)\n    i_ = 0\n    for l in multipleImages[:25]:\n        im = cv2.imread(l)\n        im = cv2.resize(im, (128, 128)) \n        plt.subplot(5, 5, i_+1) #.set_title(l)\n        plt.imshow(cv2.cvtColor(im, cv2.COLOR_BGR2RGB)); plt.axis('off')\n        i_ += 1\n        \n        \nplotImages(\"Hotel Masks in Gray Scale\",\"../input/hotel-id-to-combat-human-trafficking-2022-fgvc9/train_masks/00044.png\")","metadata":{"execution":{"iopub.status.busy":"2022-03-19T21:30:11.281572Z","iopub.execute_input":"2022-03-19T21:30:11.281896Z","iopub.status.idle":"2022-03-19T21:30:11.400188Z","shell.execute_reply.started":"2022-03-19T21:30:11.281859Z","shell.execute_reply":"2022-03-19T21:30:11.396321Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Code by Volody  https://www.kaggle.com/code/volody/threshold-segmentation\n\nimg_list = ['00026.png', '00004.png', '00000.png', '00010.png']\nfig = plt.figure(figsize=(16, 16))\nfor i in range(4):\n    x = fig.add_subplot(2, 2, i+1)\n    image = plt.imread('/kaggle/input/hotel-id-to-combat-human-trafficking-2022-fgvc9/train_masks/'+img_list[i])\n    x.set_title(\"{image} ({shape[0]},{shape[1]})\".format(image=img_list[i],shape=image.shape))\n    plt.imshow(image)","metadata":{"execution":{"iopub.status.busy":"2022-03-19T21:34:15.080876Z","iopub.execute_input":"2022-03-19T21:34:15.081142Z","iopub.status.idle":"2022-03-19T21:34:24.46316Z","shell.execute_reply.started":"2022-03-19T21:34:15.081114Z","shell.execute_reply":"2022-03-19T21:34:24.462008Z"},"_kg_hide-input":true,"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plotImages1(hotel,directory):\n    print(hotel)\n    multipleImages = glob(directory)\n    plt.rcParams['figure.figsize'] = (20, 20)\n    plt.subplots_adjust(wspace=0, hspace=0)\n    i_ = 0\n    for l in multipleImages[:25]:\n        im = cv2.imread(l)\n        im = cv2.resize(im, (128, 128)) \n        plt.subplot(5, 5, i_+1) #.set_title(l)\n        plt.imshow(cv2.cvtColor(im, cv2.COLOR_BGR2RGB)); plt.axis('off')\n        i_ += 1\n        \n        \nplotImages(\"Hotel Image in Gray Scale\",\"../input/hotel-id-to-combat-human-trafficking-2022-fgvc9/train_images/100410/000014423.jpg\")","metadata":{"_kg_hide-input":true,"execution":{"iopub.status.busy":"2022-03-19T21:54:46.707235Z","iopub.execute_input":"2022-03-19T21:54:46.707519Z","iopub.status.idle":"2022-03-19T21:54:46.940485Z","shell.execute_reply.started":"2022-03-19T21:54:46.70749Z","shell.execute_reply":"2022-03-19T21:54:46.939408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"#Below, that's the kind of masks that I expected. However, we have only those retangular/square above.","metadata":{}},{"cell_type":"markdown","source":"![](https://www.researchgate.net/profile/Robert-Pless/publication/335808593/figure/fig2/AS:802852859572225@1568426446203/Example-images-from-hotel-rooms-used-in-human-trafficking-investigations-with-the-region.ppm)researchgate.net","metadata":{}},{"cell_type":"markdown","source":"#The question is: arent't masks supposedly  to have the shape of the images? So why all are retangular or square? Unless, they are made just to frame images.","metadata":{}}]}