{"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":"from tensorflow.keras import backend as K\nimport tensorflow as tf\n\ntf.random.set_seed(0)\n\nimport math\nimport cv2\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom tensorflow.keras.datasets import mnist\nfrom tensorflow.keras import backend as K\nimport tensorflow as tf\nimport os\nimport sklearn\nfrom sklearn.model_selection import train_test_split \nfrom sklearn.metrics import classification_report\nfrom random import randint","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-07-21T01:42:35.685182Z","iopub.execute_input":"2021-07-21T01:42:35.685509Z","iopub.status.idle":"2021-07-21T01:42:40.208514Z","shell.execute_reply.started":"2021-07-21T01:42:35.685425Z","shell.execute_reply":"2021-07-21T01:42:40.20636Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Paths para las imagenes y csv:\npath='/kaggle/input/images/images/'\npath_sample_csv='/kaggle/input/cs-uni-fundamentos-de-procesamiento-de-imgenes/sample_submission (4).csv'\npath_train_csv='/kaggle/input/cs-uni-fundamentos-de-procesamiento-de-imgenes/train.csv'\n#Lectura de los csv:\n\n\n","metadata":{"execution":{"iopub.status.busy":"2021-07-21T01:42:52.112767Z","iopub.execute_input":"2021-07-21T01:42:52.113089Z","iopub.status.idle":"2021-07-21T01:42:52.117378Z","shell.execute_reply.started":"2021-07-21T01:42:52.113061Z","shell.execute_reply":"2021-07-21T01:42:52.116156Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Vista del CSV: train\ndf_train = pd.read_csv(path_train_csv)\ndf_train.head(10)","metadata":{"execution":{"iopub.status.busy":"2021-07-21T01:42:54.657944Z","iopub.execute_input":"2021-07-21T01:42:54.658312Z","iopub.status.idle":"2021-07-21T01:42:54.698413Z","shell.execute_reply.started":"2021-07-21T01:42:54.658279Z","shell.execute_reply":"2021-07-21T01:42:54.697656Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Vista del csv: muestra:\ndf_sample_csv = pd.read_csv(path_train_csv)\ndf_sample_csv.head(10)","metadata":{"execution":{"iopub.status.busy":"2021-07-21T01:42:57.813462Z","iopub.execute_input":"2021-07-21T01:42:57.813817Z","iopub.status.idle":"2021-07-21T01:42:57.832939Z","shell.execute_reply.started":"2021-07-21T01:42:57.813785Z","shell.execute_reply":"2021-07-21T01:42:57.832202Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Paths diferenciados para enfermos,sanos de entrenamiento y el path final de prueba:\npath_enfermo=[]\npath_sano=[]\npath_final=[]\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for file in filenames:\n        if file.endswith('jpeg'):\n            if(df_train.fileName.str.contains(file).any()):\n                if df_train[df_train.fileName==file].pneumonia.any()==1:\n                    path_enfermo.append(dirname+'/'+file)\n                else:\n                    path_sano.append(dirname+'/'+file)\n            else:\n                path_final.append(dirname+'/'+file)\n            ","metadata":{"execution":{"iopub.status.busy":"2021-07-21T01:42:59.979199Z","iopub.execute_input":"2021-07-21T01:42:59.979532Z","iopub.status.idle":"2021-07-21T01:43:18.796446Z","shell.execute_reply.started":"2021-07-21T01:42:59.979501Z","shell.execute_reply":"2021-07-21T01:43:18.795615Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Funcion que pre-procesa la imagen rgb a gray,la escala y la normaliza.\ndef pre_imagen_todos(paths,len_imagen):\n    imagenes_pre=np.empty(shape=(0,len_imagen,len_imagen))\n    for path in paths:\n        x=cv2.imread(path,0)\n        x=cv2.resize(x, (len_imagen,len_imagen), interpolation=cv2.INTER_AREA)\n        xmean=x.mean()\n        xstd=x.std()\n        x=(x-xmean)/xstd;\n        \n        imagenes_pre=np.append(imagenes_pre,[x],axis=0)\n    return imagenes_pre\n        ","metadata":{"execution":{"iopub.status.busy":"2021-07-21T01:43:18.79873Z","iopub.execute_input":"2021-07-21T01:43:18.799199Z","iopub.status.idle":"2021-07-21T01:43:18.809731Z","shell.execute_reply.started":"2021-07-21T01:43:18.79916Z","shell.execute_reply":"2021-07-21T01:43:18.808779Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#Funcion que pre-procesa la imagen rgb a gray,la escala y la normaliza.\ndef pre_imagen(path,len_imagen):\n    \n\n    x=cv2.imread(path,0)\n    x=cv2.resize(x, (len_imagen,len_imagen), interpolation=cv2.INTER_AREA)\n    xmean=x.mean()\n    xstd=x.std()\n    x=(x-xmean)/xstd;\n    \n    return x","metadata":{"execution":{"iopub.status.busy":"2021-07-21T01:43:25.296168Z","iopub.execute_input":"2021-07-21T01:43:25.296503Z","iopub.status.idle":"2021-07-21T01:43:25.301902Z","shell.execute_reply.started":"2021-07-21T01:43:25.296471Z","shell.execute_reply":"2021-07-21T01:43:25.300778Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len_imagenes=224\nX=np.empty(shape=(0,len_imagenes,len_imagenes))\ny=np.array([])\n\nfor path in path_enfermo:\n    X=np.append(X,[pre_imagen(path,len_imagenes)],axis=0)\n    y=np.append(y,1.0)\n    \nfor path in path_sano:\n    X=np.append(X,[pre_imagen(path,len_imagenes)],axis=0)\n    y=np.append(y,0.0)","metadata":{"execution":{"iopub.status.busy":"2021-07-21T01:43:28.210175Z","iopub.execute_input":"2021-07-21T01:43:28.210498Z","iopub.status.idle":"2021-07-21T01:56:25.628558Z","shell.execute_reply.started":"2021-07-21T01:43:28.210466Z","shell.execute_reply":"2021-07-21T01:56:25.627387Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(X.shape)\nprint(y.shape)","metadata":{"execution":{"iopub.status.busy":"2021-07-21T02:06:58.771409Z","iopub.execute_input":"2021-07-21T02:06:58.771755Z","iopub.status.idle":"2021-07-21T02:06:58.777816Z","shell.execute_reply.started":"2021-07-21T02:06:58.771715Z","shell.execute_reply":"2021-07-21T02:06:58.776753Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train, x_test,y_train, y_test = train_test_split(X,y, test_size=0.2, random_state=0,stratify=y)","metadata":{"execution":{"iopub.status.busy":"2021-07-21T02:07:01.181756Z","iopub.execute_input":"2021-07-21T02:07:01.182077Z","iopub.status.idle":"2021-07-21T02:07:01.534416Z","shell.execute_reply.started":"2021-07-21T02:07:01.182048Z","shell.execute_reply":"2021-07-21T02:07:01.533546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train.min(), x_train.max()","metadata":{"execution":{"iopub.status.busy":"2021-07-21T02:07:03.653354Z","iopub.execute_input":"2021-07-21T02:07:03.653701Z","iopub.status.idle":"2021-07-21T02:07:03.822532Z","shell.execute_reply.started":"2021-07-21T02:07:03.653651Z","shell.execute_reply":"2021-07-21T02:07:03.821596Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(x_train[0], cmap=\"gray\");","metadata":{"execution":{"iopub.status.busy":"2021-07-21T02:07:05.147461Z","iopub.execute_input":"2021-07-21T02:07:05.148116Z","iopub.status.idle":"2021-07-21T02:07:05.43519Z","shell.execute_reply.started":"2021-07-21T02:07:05.148063Z","shell.execute_reply":"2021-07-21T02:07:05.434391Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train[0]","metadata":{"execution":{"iopub.status.busy":"2021-07-21T02:07:08.621549Z","iopub.execute_input":"2021-07-21T02:07:08.621949Z","iopub.status.idle":"2021-07-21T02:07:08.62857Z","shell.execute_reply.started":"2021-07-21T02:07:08.621914Z","shell.execute_reply":"2021-07-21T02:07:08.627443Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train[0][0]","metadata":{"execution":{"iopub.status.busy":"2021-07-21T02:07:12.784328Z","iopub.execute_input":"2021-07-21T02:07:12.784743Z","iopub.status.idle":"2021-07-21T02:07:12.794152Z","shell.execute_reply.started":"2021-07-21T02:07:12.784691Z","shell.execute_reply":"2021-07-21T02:07:12.793004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train.ndim","metadata":{"execution":{"iopub.status.busy":"2021-07-21T02:07:17.227304Z","iopub.execute_input":"2021-07-21T02:07:17.22765Z","iopub.status.idle":"2021-07-21T02:07:17.237107Z","shell.execute_reply.started":"2021-07-21T02:07:17.227619Z","shell.execute_reply":"2021-07-21T02:07:17.235862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Ajustamos las dimensiones de las imágenes\nif x_train.ndim == 3:\n    x_train = x_train[...,None]\n    x_test = x_test[..., None]\n    print(x_train.shape, x_test.shape)","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:58:08.558116Z","iopub.execute_input":"2021-07-20T00:58:08.558436Z","iopub.status.idle":"2021-07-20T00:58:08.563853Z","shell.execute_reply.started":"2021-07-20T00:58:08.558405Z","shell.execute_reply":"2021-07-20T00:58:08.562868Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train[0][0]","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:58:12.012172Z","iopub.execute_input":"2021-07-20T00:58:12.012496Z","iopub.status.idle":"2021-07-20T00:58:12.022143Z","shell.execute_reply.started":"2021-07-20T00:58:12.012465Z","shell.execute_reply":"2021-07-20T00:58:12.021283Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def plot_model_and_save_image(model, file_name=\"model.png\"):   \n    from tensorflow.keras.utils import plot_model\n    return plot_model(model, to_file=file_name, show_shapes=True)","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:58:18.959239Z","iopub.execute_input":"2021-07-20T00:58:18.959557Z","iopub.status.idle":"2021-07-20T00:58:18.964225Z","shell.execute_reply.started":"2021-07-20T00:58:18.959525Z","shell.execute_reply":"2021-07-20T00:58:18.963038Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Model\nimport tensorflow.python.keras\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, Conv2D, MaxPool2D, Flatten\nfrom tensorflow.keras.optimizers import SGD\nfrom tensorflow.keras.optimizers import SGD, Adam, RMSprop, Adagrad\nfrom tensorflow.keras.models import Model\nfrom tensorflow.keras.layers import Dense, Conv2D, MaxPool2D, Flatten,GlobalAvgPool2D, GlobalMaxPool2D, Dropout, BatchNormalization,concatenate, Layer, Input\nfrom tensorflow.keras.regularizers import l2\nfrom tensorflow.keras.optimizers import SGD\nfrom tensorflow.keras import backend as K","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:58:24.932362Z","iopub.execute_input":"2021-07-20T00:58:24.932745Z","iopub.status.idle":"2021-07-20T00:58:24.938462Z","shell.execute_reply.started":"2021-07-20T00:58:24.932708Z","shell.execute_reply":"2021-07-20T00:58:24.937534Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tf.__version__","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:58:28.08435Z","iopub.execute_input":"2021-07-20T00:58:28.08469Z","iopub.status.idle":"2021-07-20T00:58:28.089873Z","shell.execute_reply.started":"2021-07-20T00:58:28.084643Z","shell.execute_reply":"2021-07-20T00:58:28.088944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%writefile custom_callbacks.py\nimport tensorflow.python.keras\nimport tensorflow.python.keras, math\nimport numpy as np\nimport tensorflow as tf\nfrom tensorflow.python.keras import backend as K\nimport matplotlib.pyplot as plt\nfrom pathlib import Path\nimport os\n\ndef save_weights(model, file):\n    model.save_weights(file, overwrite=True)\n\ndef reset_weights(model, file):\n    model.load_weights(file)\n\n\n\n\n","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:58:30.064077Z","iopub.execute_input":"2021-07-20T00:58:30.0644Z","iopub.status.idle":"2021-07-20T00:58:30.069993Z","shell.execute_reply.started":"2021-07-20T00:58:30.06437Z","shell.execute_reply":"2021-07-20T00:58:30.068907Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from custom_callbacks import  reset_weights, save_weights","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:58:33.282371Z","iopub.execute_input":"2021-07-20T00:58:33.282722Z","iopub.status.idle":"2021-07-20T00:58:33.289977Z","shell.execute_reply.started":"2021-07-20T00:58:33.282687Z","shell.execute_reply":"2021-07-20T00:58:33.289057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#eliminar el modelo si es que existe\n#del model","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:59:10.09632Z","iopub.execute_input":"2021-07-20T00:59:10.096745Z","iopub.status.idle":"2021-07-20T00:59:10.101087Z","shell.execute_reply.started":"2021-07-20T00:59:10.096706Z","shell.execute_reply":"2021-07-20T00:59:10.100284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Model\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, Conv2D, MaxPool2D, Flatten\nfrom tensorflow.keras.optimizers import SGD\nfrom tensorflow.keras.optimizers import SGD, Adam, RMSprop, Adagrad\nfrom tensorflow.keras.models import Model\nfrom tensorflow.keras.layers import Dense, Conv2D, MaxPool2D, Flatten,GlobalAvgPool2D, GlobalMaxPool2D, Dropout, BatchNormalization,concatenate, Layer, Input\nfrom tensorflow.keras.regularizers import l2\nfrom tensorflow.keras.optimizers import SGD\nfrom tensorflow.keras import backend as K\n\nK.clear_session()\n\nlr = 0.01\nbs = 256\nnb = math.ceil(len(x_train)/bs) # Nro de batches\nl2_w = 1e-4\n\nmodel_in = Input((len_imagenes,len_imagenes,1))\n\nx = model_in\nfor k in [32,32,64,128,128]:\n  x = Conv2D(k, 3, strides=2, activation='relu', kernel_initializer='he_normal', use_bias=False, kernel_regularizer=l2(l2_w))(x)\n  x = BatchNormalization()(x)\n\nx_avg = GlobalAvgPool2D()(x)\nx_max = GlobalMaxPool2D()(x)\nx = concatenate([x_avg, x_max])\nx = Dropout(0.25)(x)\n\nmodel_out = Dense(2, activation='softmax', kernel_regularizer=l2(l2_w))(x)\n\nmodel = Model(model_in, model_out)\n\nmodel.compile(optimizer=Adam(lr), loss='sparse_categorical_crossentropy', metrics=['accuracy'])\nsave_weights(model, 'model')\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:59:12.940987Z","iopub.execute_input":"2021-07-20T00:59:12.941323Z","iopub.status.idle":"2021-07-20T00:59:13.082113Z","shell.execute_reply.started":"2021-07-20T00:59:12.941292Z","shell.execute_reply":"2021-07-20T00:59:13.081265Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plot_model_and_save_image(model, file_name=\"model.png\")","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:58:51.813859Z","iopub.execute_input":"2021-07-20T00:58:51.814217Z","iopub.status.idle":"2021-07-20T00:58:52.398306Z","shell.execute_reply.started":"2021-07-20T00:58:51.814185Z","shell.execute_reply":"2021-07-20T00:58:52.397279Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Trainning\n\nlog = model.fit(x_train, y_train, batch_size=bs, epochs=30, validation_data=(x_test, y_test))","metadata":{"execution":{"iopub.status.busy":"2021-07-20T00:59:26.960597Z","iopub.execute_input":"2021-07-20T00:59:26.961042Z","iopub.status.idle":"2021-07-20T00:59:57.677607Z","shell.execute_reply.started":"2021-07-20T00:59:26.961004Z","shell.execute_reply":"2021-07-20T00:59:57.676782Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(log.history['loss'], label='train')\nplt.plot(log.history['val_loss'], label='test')\nplt.legend();","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:00:37.214434Z","iopub.execute_input":"2021-07-20T01:00:37.214809Z","iopub.status.idle":"2021-07-20T01:00:37.399235Z","shell.execute_reply.started":"2021-07-20T01:00:37.214772Z","shell.execute_reply":"2021-07-20T01:00:37.398203Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def show_results(model, log):\n    loss, acc = model.evaluate(x_test, y_test, batch_size=512, verbose=False)\n    print(f'Loss     = {loss:.4f}')\n    print(f'Accuracy = {acc:.4f}')\n    \n    val_loss = log.history['val_loss']\n    val_acc = log.history['val_accuracy']\n        \n    fig, axes = plt.subplots(1, 2, figsize=(14,4))\n    ax1, ax2 = axes\n    ax1.plot(log.history['loss'], label='train')\n    ax1.plot(val_loss, label='test')\n    ax1.set_xlabel('epoch'); ax1.set_ylabel('loss')\n    ax2.plot(log.history['accuracy'], label='train')\n    ax2.plot(val_acc, label='test')\n    ax2.set_xlabel('epoch'); ax2.set_ylabel('accuracy')\n    for ax in axes: ax.legend()","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:00:40.321574Z","iopub.execute_input":"2021-07-20T01:00:40.321998Z","iopub.status.idle":"2021-07-20T01:00:40.329423Z","shell.execute_reply.started":"2021-07-20T01:00:40.321967Z","shell.execute_reply":"2021-07-20T01:00:40.328551Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_results(model, log)","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:00:43.377949Z","iopub.execute_input":"2021-07-20T01:00:43.378278Z","iopub.status.idle":"2021-07-20T01:00:44.313941Z","shell.execute_reply.started":"2021-07-20T01:00:43.378247Z","shell.execute_reply":"2021-07-20T01:00:44.313113Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_final=pre_imagen(path_final[0],len_imagenes)\nprint(x_final.ndim)","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:11:20.305064Z","iopub.execute_input":"2021-07-20T01:11:20.305381Z","iopub.status.idle":"2021-07-20T01:11:20.318584Z","shell.execute_reply.started":"2021-07-20T01:11:20.305353Z","shell.execute_reply":"2021-07-20T01:11:20.317644Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fila=[]\nx_final=np.empty(shape=(0,len_imagenes,len_imagenes))\nfor path in path_final:\n    x_final=np.append(x_final,[pre_imagen(path,len_imagenes)],axis=0)\n\nif x_final.ndim == 3:\n    x_final = x_final[...,None]\n    \n    \n    \n\n","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:15:07.659777Z","iopub.execute_input":"2021-07-20T01:15:07.660101Z","iopub.status.idle":"2021-07-20T01:16:45.418383Z","shell.execute_reply.started":"2021-07-20T01:15:07.660072Z","shell.execute_reply":"2021-07-20T01:16:45.417426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(x_final.shape)","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:17:43.329481Z","iopub.execute_input":"2021-07-20T01:17:43.329892Z","iopub.status.idle":"2021-07-20T01:17:43.334278Z","shell.execute_reply.started":"2021-07-20T01:17:43.329857Z","shell.execute_reply":"2021-07-20T01:17:43.333317Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y=model.predict(x_final)","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:17:49.183012Z","iopub.execute_input":"2021-07-20T01:17:49.183387Z","iopub.status.idle":"2021-07-20T01:17:49.752706Z","shell.execute_reply.started":"2021-07-20T01:17:49.183348Z","shell.execute_reply":"2021-07-20T01:17:49.751497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y[0,1]","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:19:28.383911Z","iopub.execute_input":"2021-07-20T01:19:28.384322Z","iopub.status.idle":"2021-07-20T01:19:28.390077Z","shell.execute_reply.started":"2021-07-20T01:19:28.38429Z","shell.execute_reply":"2021-07-20T01:19:28.389021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fila=[]\nfor i in range(1025):\n    fila.append([path_final[i].split('/')[-1],y[i,1]])\ndf=pd.DataFrame(fila,columns=['fileName','pneumonia'])\ndf.to_csv('FinalG6.csv',index = False)","metadata":{"execution":{"iopub.status.busy":"2021-07-20T01:29:26.955011Z","iopub.execute_input":"2021-07-20T01:29:26.955336Z","iopub.status.idle":"2021-07-20T01:29:26.970481Z","shell.execute_reply.started":"2021-07-20T01:29:26.955307Z","shell.execute_reply":"2021-07-20T01:29:26.96958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}