Files
arrest-tb/image processing and models/arrest-tb-trial-1__1_.ipynb

1 line
81 KiB
Plaintext
Raw Normal View History

2020-10-22 09:50:14 +00:00
{"cells":[{"metadata":{"trusted":true},"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 in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../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# Any results you write to the current directory are saved as output.","execution_count":1,"outputs":[{"output_type":"stream","text":"/kaggle/input/mycotb1/myco/validation/negative/e_images_19.jpg\n/kaggle/input/mycotb1/myco/validation/negative/e_images_20.jpg\n/kaggle/input/mycotb1/myco/validation/negative/e_images_18.jpg\n/kaggle/input/mycotb1/myco/validation/positive/e_images_9.jpg\n/kaggle/input/mycotb1/myco/validation/positive/e_images_7.jpg\n/kaggle/input/mycotb1/myco/validation/positive/e_images_8.jpg\n/kaggle/input/mycotb1/myco/testing/negative/e_images_11.jpg\n/kaggle/input/mycotb1/myco/testing/negative/e_images_10.jpg\n/kaggle/input/mycotb1/myco/testing/negative/e_images_13.jpg\n/kaggle/input/mycotb1/myco/testing/negative/e_images_14.jpg\n/kaggle/input/mycotb1/myco/testing/negative/e_images_12.jpg\n/kaggle/input/mycotb1/myco/testing/positive/e_images_4.jpg\n/kaggle/input/mycotb1/myco/testing/positive/e_images_3.jpg\n/kaggle/input/mycotb1/myco/testing/positive/e_images_2.jpg\n/kaggle/input/mycotb1/myco/testing/positive/e_images_1.jpg\n/kaggle/input/mycotb1/myco/training/negative/e_images_16.jpg\n/kaggle/input/mycotb1/myco/training/negative/e_images_17.jpg\n/kaggle/input/mycotb1/myco/training/negative/e_images_15.jpg\n/kaggle/input/mycotb1/myco/training/positive/e_images_5.jpg\n/kaggle/input/mycotb1/myco/training/positive/e_images_7.jpg\n/kaggle/input/mycotb1/myco/training/positive/e_images_6.jpg\n","name":"stdout"}]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"import numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom matplotlib import pyplot as plt #Ploting charts\nfrom glob import glob #retriving an array of files in directories\nfrom keras.models import Sequential #for neural network models\nfrom keras.layers import Dense, Dropout, Flatten, ZeroPadding2D, Conv2D, MaxPooling2D\nfrom keras.preprocessing.image import ImageDataGenerator #Data augmentation and preprocessing\nfrom keras.utils import to_categorical #For One-hot Encoding\nfrom keras.optimizers import Adam, SGD, RMSprop #For Optimizing the Neural Network\nfrom keras.callbacks import EarlyStopping","execution_count":2,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import os\npaths = os.listdir(path=\"../input\")\nprint(paths)","execution_count":3,"outputs":[{"output_type":"stream","text":"['mycotb1']\n","name":"stdout"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"path_train = \"../input/mycotb1/myco/training\"\npath_val = \"../input/mycotb1/myco/validation\"\npath_test = \"../input/mycotb1/myco/testing\"\npath_train","execution_count":4,"outputs":[{"output_type":"execute_result","execution_count":4,"data":{"text/plain":"'../input/mycotb1/myco/training'"},"metadata":{}}]},{"metadata":{"trusted":true},"cell_type":"code","source":"img = glob(path_train+\"/negative/*.jpg\")","execution_count":5,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"img = glob(path_train+\"/negative/*.jpg\") #Getting all images in this folder\nimg = np.asarray(plt.imread(img[0]))\nplt.imshow(img)","execution_count":6,"outputs":[{"output_type":"execute_result","execution_count":6,"data":{"text/plain":"<matplotlib