1 line
458 KiB
Plaintext
1 line
458 KiB
Plaintext
|
|
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.10","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"#import tensor flow\nimport tensorflow as tf","metadata":{"execution":{"iopub.status.busy":"2021-09-03T17:50:35.562279Z","iopub.execute_input":"2021-09-03T17:50:35.562756Z","iopub.status.idle":"2021-09-03T17:50:35.567291Z","shell.execute_reply.started":"2021-09-03T17:50:35.562721Z","shell.execute_reply":"2021-09-03T17:50:35.566196Z"},"trusted":true},"execution_count":57,"outputs":[]},{"cell_type":"code","source":"#import all libraries\nimport numpy as np\nimport os\nfrom sklearn.metrics import confusion_matrix\nimport seaborn as sn; sn.set(font_scale=1.4)\nfrom sklearn.utils import shuffle\nfrom keras.callbacks import ModelCheckpoint,EarlyStopping\nfrom keras.layers import Conv2D, Flatten, MaxPooling2D,Dense,Dropout,SpatialDropout2D\nfrom keras.models import Sequential\nfrom keras.preprocessing.image import ImageDataGenerator, img_to_array, load_img, array_to_img\nimport matplotlib.pyplot as plt \nimport cv2 \nimport tensorflow as tf \nfrom tqdm import tqdm\nfrom sklearn.metrics import classification_report\nfrom sklearn.model_selection import train_test_split\nimport numpy as np","metadata":{"execution":{"iopub.status.busy":"2021-09-03T17:50:35.571717Z","iopub.execute_input":"2021-09-03T17:50:35.572054Z","iopub.status.idle":"2021-09-03T17:50:35.581855Z","shell.execute_reply.started":"2021-09-03T17:50:35.572025Z","shell.execute_reply":"2021-09-03T17:50:35.580803Z"},"trusted":true},"execution_count":58,"outputs":[]},{"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","metadata":{"execution":{"iopub.status.busy":"2021-09-03T17:50:35.604996Z","iopub.execute_input":"2021-09-03T17:50:35.605653Z","iopub.status.idle":"2021-09-03T17:50:35.612147Z","shell.execute_reply.started":"2021-09-03T17:50:35.605617Z","shell.execute_reply":"2021-09-03T17:50:35.610449Z"},"trusted":true},"execution_count":59,"outputs":[]},{"cell_type":"code","source":"class_names = ['negative','positive']\nclass_names_label = {class_name:i for i, class_name in enumerate(class_names)}\n\nnb_classes = len(class_names)\n\nIMAGE_SIZE = (224,224)","metadata":{"execution":{"iopub.status.busy":"2021-09-03T17:50:35.615876Z","iopub.execute_input":"2021-09-03T17:50:35.616288Z","iopub.status.idle":"2021-09-03T17:50:35.625623Z","shell.execute_reply.started":"2021-09-03T17:50:35.616254Z","shell.execute_reply":"2021-09-03T17:50:35.624280Z"},"trusted":true},"execution_count":60,"outputs":[]},{"cell_type":"code","source":"#load the data\ndef load_data():\n \"\"\"\n Load the data:\n - 14,034 images to train the network.\n - 3,000 images to evaluate how accurately the network learned to classify images.\n \"\"\"\n \n datasets = [\"../input/arresttbdata/training/training\", \"../input/arresttbdata/testing\"]\n output = []\n \n # Iterate through training and test sets\n for dataset in datasets:\n \n images = []\n labels = []\n \n print(\"Loading {}\".format(dataset))\n \n # Iterate through each folder corresponding to a ca
|