{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":3362,"databundleVersionId":31148,"sourceType":"competition"}],"dockerImageVersionId":30648,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os,shutil","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:08:57.331738Z","iopub.execute_input":"2024-02-16T20:08:57.332158Z","iopub.status.idle":"2024-02-16T20:08:57.344033Z","shell.execute_reply.started":"2024-02-16T20:08:57.332120Z","shell.execute_reply":"2024-02-16T20:08:57.343039Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import zipfile","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:08:57.345793Z","iopub.execute_input":"2024-02-16T20:08:57.346040Z","iopub.status.idle":"2024-02-16T20:08:57.354267Z","shell.execute_reply.started":"2024-02-16T20:08:57.346018Z","shell.execute_reply":"2024-02-16T20:08:57.353234Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"zip_file_path = \"/kaggle/input/dogs-vs-cats/train.zip\"","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:08:57.355306Z","iopub.execute_input":"2024-02-16T20:08:57.355589Z","iopub.status.idle":"2024-02-16T20:08:57.363123Z","shell.execute_reply.started":"2024-02-16T20:08:57.355548Z","shell.execute_reply":"2024-02-16T20:08:57.362064Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"odir = \"/kaggle/working/new\"","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:08:57.364391Z","iopub.execute_input":"2024-02-16T20:08:57.364755Z","iopub.status.idle":"2024-02-16T20:08:57.371670Z","shell.execute_reply.started":"2024-02-16T20:08:57.364724Z","shell.execute_reply":"2024-02-16T20:08:57.370714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.makedirs(odir, exist_ok=True)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:08:57.376380Z","iopub.execute_input":"2024-02-16T20:08:57.377276Z","iopub.status.idle":"2024-02-16T20:08:57.381369Z","shell.execute_reply.started":"2024-02-16T20:08:57.377240Z","shell.execute_reply":"2024-02-16T20:08:57.380509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with zipfile.ZipFile(zip_file_path, 'r') as zip_ref:\n    zip_ref.extractall(odir)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:08:57.382341Z","iopub.execute_input":"2024-02-16T20:08:57.382587Z","iopub.status.idle":"2024-02-16T20:09:03.824341Z","shell.execute_reply.started":"2024-02-16T20:08:57.382559Z","shell.execute_reply":"2024-02-16T20:09:03.823487Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"bdir='/kaggle/working/dogs-cats'\nos.mkdir(bdir)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tdir=os.path.join(bdir,'train')\nos.mkdir(tdir)\nvdir=os.path.join(bdir,'validation')\nos.mkdir(vdir)\ntestdir=os.path.join(bdir,'test')\nos.mkdir(testdir)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:07.519142Z","iopub.execute_input":"2024-02-16T20:10:07.519940Z","iopub.status.idle":"2024-02-16T20:10:07.525363Z","shell.execute_reply.started":"2024-02-16T20:10:07.519909Z","shell.execute_reply":"2024-02-16T20:10:07.524412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"tcd=os.path.join(tdir,'cats')\nos.mkdir(tcd)\ntdd=os.path.join(tdir,'dogs')\nos.mkdir(tdd)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:27.890844Z","iopub.execute_input":"2024-02-16T20:10:27.891465Z","iopub.status.idle":"2024-02-16T20:10:27.897554Z","shell.execute_reply.started":"2024-02-16T20:10:27.891422Z","shell.execute_reply":"2024-02-16T20:10:27.896503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"vcd=os.path.join(vdir,'cats')\nos.mkdir(vcd)\nvdd=os.path.join(vdir,'dogs')\nos.mkdir(vdd)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:27.899205Z","iopub.execute_input":"2024-02-16T20:10:27.899590Z","iopub.status.idle":"2024-02-16T20:10:27.907092Z","shell.execute_reply.started":"2024-02-16T20:10:27.899557Z","shell.execute_reply":"2024-02-16T20:10:27.906073Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"testcd=os.path.join(testdir,'cats')\nos.mkdir(testcd)\ntestdd=os.path.join(testdir,'dogs')\nos.mkdir(testdd)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:27.908311Z","iopub.execute_input":"2024-02-16T20:10:27.908610Z","iopub.status.idle":"2024-02-16T20:10:27.916174Z","shell.execute_reply.started":"2024-02-16T20:10:27.908585Z","shell.execute_reply":"2024-02-16T20:10:27.915251Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_names = os.listdir(odir+'/train/')\nfile_names[0]","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:27.918344Z","iopub.execute_input":"2024-02-16T20:10:27.918649Z","iopub.status.idle":"2024-02-16T20:10:27.941462Z","shell.execute_reply.started":"2024-02-16T20:10:27.918624Z","shell.execute_reply":"2024-02-16T20:10:27.940641Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from PIL import Image\n\n# Directory path\ndirectory_path = odir+'/train/'\n\n# Get list of image files in the directory\nimage_files = [f for f in os.listdir(directory_path) if f.endswith(('.png', '.jpg', '.jpeg', '.gif'))]\n\n# Check if there are any image files in the directory\nif len(image_files) == 0:\n    print(\"No image files found in the directory.\")\nelse:\n    # Get dimensions of the first image file\n    first_image = Image.open(os.path.join(directory_path, image_files[0]))\n    first_dimensions = first_image.size\n\n    # Check dimensions of other image files\n    same_dimensions = True\n    for image_file in image_files[1:]:\n        image_path = os.path.join(directory_path, image_file)\n        image = Image.open(image_path)\n        if image.size != first_dimensions:\n            same_dimensions = False\n\n    if same_dimensions:\n        print(\"All image files have the same dimensions.\")\n    else:\n        print(\"Not all image files have the same dimensions.\")\n","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:27.942505Z","iopub.execute_input":"2024-02-16T20:10:27.942752Z","iopub.status.idle":"2024-02-16T20:10:30.638446Z","shell.execute_reply.started":"2024-02-16T20:10:27.942731Z","shell.execute_reply":"2024-02-16T20:10:30.637430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fnames=['cat.{}.jpg'.format(i) for i in range(1000)]\nfor fname in fnames:\n    src=os.path.join(odir+'/train/',fname)\n    dst=os.path.join(tcd,fname)\n    shutil.copyfile(src,dst)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:30.639927Z","iopub.execute_input":"2024-02-16T20:10:30.640584Z","iopub.status.idle":"2024-02-16T20:10:30.758140Z","shell.execute_reply.started":"2024-02-16T20:10:30.640546Z","shell.execute_reply":"2024-02-16T20:10:30.757397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fnames=['cat.{}.jpg'.format(i) for i in range(1000,1500)]\nfor fname in fnames:\n    src=os.path.join(odir+'/train/',fname)\n    dst=os.path.join(vcd,fname)\n    shutil.copyfile(src,dst)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:30.759196Z","iopub.execute_input":"2024-02-16T20:10:30.759474Z","iopub.status.idle":"2024-02-16T20:10:30.818624Z","shell.execute_reply.started":"2024-02-16T20:10:30.759449Z","shell.execute_reply":"2024-02-16T20:10:30.817730Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fnames=['cat.{}.jpg'.format(i) for i in range(1500,2000)]\nfor fname in fnames:\n    src=os.path.join(odir+'/train/',fname)\n    dst=os.path.join(testcd,fname)\n    shutil.copyfile(src,dst)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:30.819697Z","iopub.execute_input":"2024-02-16T20:10:30.819949Z","iopub.status.idle":"2024-02-16T20:10:30.881240Z","shell.execute_reply.started":"2024-02-16T20:10:30.819926Z","shell.execute_reply":"2024-02-16T20:10:30.880509Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fnames=['dog.{}.jpg'.format(i) for i in range(1000)]\nfor fname in fnames:\n    src=os.path.join(odir+'/train/',fname)\n    dst=os.path.join(tdd,fname)\n    shutil.copyfile(src,dst)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:30.882415Z","iopub.execute_input":"2024-02-16T20:10:30.883095Z","iopub.status.idle":"2024-02-16T20:10:30.994079Z","shell.execute_reply.started":"2024-02-16T20:10:30.883035Z","shell.execute_reply":"2024-02-16T20:10:30.993151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fnames=['dog.{}.jpg'.format(i) for i in range(1000,1500)]\nfor fname in fnames:\n    src=os.path.join(odir+'/train/',fname)\n    dst=os.path.join(vdd,fname)\n    shutil.copyfile(src,dst)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:30.998501Z","iopub.execute_input":"2024-02-16T20:10:30.998781Z","iopub.status.idle":"2024-02-16T20:10:31.058711Z","shell.execute_reply.started":"2024-02-16T20:10:30.998757Z","shell.execute_reply":"2024-02-16T20:10:31.058028Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fnames=['cat.{}.jpg'.format(i) for i in range(1500,2000)]\nfor fname in fnames:\n    src=os.path.join(odir+'/train/',fname)\n    dst=os.path.join(testdd,fname)\n    shutil.copyfile(src,dst)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:31.059691Z","iopub.execute_input":"2024-02-16T20:10:31.060008Z","iopub.status.idle":"2024-02-16T20:10:31.119715Z","shell.execute_reply.started":"2024-02-16T20:10:31.059977Z","shell.execute_reply":"2024-02-16T20:10:31.118871Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(len(os.listdir(tcd)),len(os.listdir(vcd)),len(os.listdir(testcd)),len(os.listdir(tdd)),len(os.listdir(vdd)),len(os.listdir(testdd)))","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:31.120928Z","iopub.execute_input":"2024-02-16T20:10:31.121283Z","iopub.status.idle":"2024-02-16T20:10:31.130420Z","shell.execute_reply.started":"2024-02-16T20:10:31.121251Z","shell.execute_reply":"2024-02-16T20:10:31.129338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras import layers\nfrom keras import models","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:31.132533Z","iopub.execute_input":"2024-02-16T20:10:31.132798Z","iopub.status.idle":"2024-02-16T20:10:44.404022Z","shell.execute_reply.started":"2024-02-16T20:10:31.132775Z","shell.execute_reply":"2024-02-16T20:10:44.403229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model=models.Sequential()\nmodel.add(layers.Conv2D(32,(3,3),activation='relu',input_shape=(150,150,3)))\nmodel.add(layers.MaxPooling2D((2,2)))\nmodel.add(layers.Conv2D(64,(3,3),activation='relu'))\nmodel.add(layers.MaxPooling2D((2,2)))\nmodel.add(layers.Conv2D(128,(3,3),activation='relu'))\nmodel.add(layers.MaxPooling2D((2,2)))\nmodel.add(layers.Conv2D(128,(3,3),activation='relu'))\nmodel.add(layers.MaxPooling2D((2,2)))\nmodel.add(layers.Flatten())\nmodel.add(layers.Dense(512,activation='relu'))\nmodel.add(layers.Dense(1,activation='sigmoid'))","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:44.405235Z","iopub.execute_input":"2024-02-16T20:10:44.405908Z","iopub.status.idle":"2024-02-16T20:10:45.311592Z","shell.execute_reply.started":"2024-02-16T20:10:44.405869Z","shell.execute_reply":"2024-02-16T20:10:45.310632Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.summary()","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:45.312963Z","iopub.execute_input":"2024-02-16T20:10:45.313376Z","iopub.status.idle":"2024-02-16T20:10:45.347164Z","shell.execute_reply.started":"2024-02-16T20:10:45.313341Z","shell.execute_reply":"2024-02-16T20:10:45.346312Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras import optimizers\nmodel.compile(loss='binary_crossentropy',optimizer=optimizers.RMSprop(lr=1e-4),metrics=['acc'])","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:45.348211Z","iopub.execute_input":"2024-02-16T20:10:45.348464Z","iopub.status.idle":"2024-02-16T20:10:45.366413Z","shell.execute_reply.started":"2024-02-16T20:10:45.348441Z","shell.execute_reply":"2024-02-16T20:10:45.365528Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.preprocessing.image import ImageDataGenerator as idg\ntrain_datagen = idg(rescale=1./255)\ntest_datagen = idg(rescale=1./255)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:45.367466Z","iopub.execute_input":"2024-02-16T20:10:45.367730Z","iopub.status.idle":"2024-02-16T20:10:45.372446Z","shell.execute_reply.started":"2024-02-16T20:10:45.367706Z","shell.execute_reply":"2024-02-16T20:10:45.371461Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_generator=train_datagen.flow_from_directory(tdir,target_size=(150,150),batch_size=20,class_mode='binary')","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:45.373460Z","iopub.execute_input":"2024-02-16T20:10:45.373718Z","iopub.status.idle":"2024-02-16T20:10:45.441429Z","shell.execute_reply.started":"2024-02-16T20:10:45.373695Z","shell.execute_reply":"2024-02-16T20:10:45.440741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"validation_generator=test_datagen.flow_from_directory(vdir,target_size=(150,150),batch_size=20,class_mode='binary')","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:45.442318Z","iopub.execute_input":"2024-02-16T20:10:45.442540Z","iopub.status.idle":"2024-02-16T20:10:45.481011Z","shell.execute_reply.started":"2024-02-16T20:10:45.442520Z","shell.execute_reply":"2024-02-16T20:10:45.480245Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for db,lb in train_generator:\n    print(db)\n    print(lb)\n    break","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:45.482092Z","iopub.execute_input":"2024-02-16T20:10:45.482390Z","iopub.status.idle":"2024-02-16T20:10:45.533353Z","shell.execute_reply.started":"2024-02-16T20:10:45.482366Z","shell.execute_reply":"2024-02-16T20:10:45.532290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history=model.fit_generator(train_generator,\n                           steps_per_epoch=100,\n                           epochs=30,\n                           validation_data=validation_generator,\n                           validation_steps=50)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:10:45.534894Z","iopub.execute_input":"2024-02-16T20:10:45.535268Z","iopub.status.idle":"2024-02-16T20:13:08.939607Z","shell.execute_reply.started":"2024-02-16T20:10:45.535240Z","shell.execute_reply":"2024-02-16T20:13:08.938811Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.save('first')","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:13:08.940794Z","iopub.execute_input":"2024-02-16T20:13:08.941083Z","iopub.status.idle":"2024-02-16T20:13:10.210248Z","shell.execute_reply.started":"2024-02-16T20:13:08.941051Z","shell.execute_reply":"2024-02-16T20:13:10.209401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nacc=history.history['acc']\nval_acc=history.history['val_acc']\nloss=history.history['loss']\nval_loss=history.history['val_loss']\n\nepochs=range(1,len(acc)+1)\n\nplt.plot(epochs,acc,'bo')\nplt.plot(epochs,val_acc,'bo')\nplt.legend()\n\nplt.figure()\n\nplt.plot(epochs,loss,'bo')\nplt.plot(epochs,val_loss,'bo')\nplt.legend()\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:13:10.211619Z","iopub.execute_input":"2024-02-16T20:13:10.212274Z","iopub.status.idle":"2024-02-16T20:13:10.592059Z","shell.execute_reply.started":"2024-02-16T20:13:10.212236Z","shell.execute_reply":"2024-02-16T20:13:10.591129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"datagen=idg(rotation_range=40,\n                           width_shift_range=0.2,\n                           height_shift_range=0.2,\n                           shear_range=0.2,\n                           zoom_range=0.2,\n                           horizontal_flip=True,\n                           fill_mode='nearest'\n                          )","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:13:10.593416Z","iopub.execute_input":"2024-02-16T20:13:10.593787Z","iopub.status.idle":"2024-02-16T20:13:10.599476Z","shell.execute_reply.started":"2024-02-16T20:13:10.593755Z","shell.execute_reply":"2024-02-16T20:13:10.598521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.preprocessing import image\nfnames=[os.path.join(tcd,fname) for fname in os.listdir(tcd)]\nimg_path=fnames[0]\nimg=image.load_img(img_path,target_size=(150,150))\nx=image.img_to_array(img)\nx=x.reshape((1,)+ x.shape)\ni=0\nfor batch in datagen.flow(x,batch_size=1):\n    plt.figure(i)\n    imgplot=plt.imshow(image.array_to_img(batch[0]))\n    i+=1\n    if i%4==0:\n        break\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:13:10.600571Z","iopub.execute_input":"2024-02-16T20:13:10.600898Z","iopub.status.idle":"2024-02-16T20:13:11.626013Z","shell.execute_reply.started":"2024-02-16T20:13:10.600873Z","shell.execute_reply":"2024-02-16T20:13:11.625051Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2=models.Sequential()\nmodel2.add(layers.Conv2D(32,(3,3),activation='relu',input_shape=(150,150,3)))\nmodel2.add(layers.MaxPooling2D((2,2)))\nmodel2.add(layers.Conv2D(64,(3,3),activation='relu'))\nmodel2.add(layers.MaxPooling2D((2,2)))\nmodel2.add(layers.Conv2D(128,(3,3),activation='relu'))\nmodel2.add(layers.MaxPooling2D((2,2)))\nmodel2.add(layers.Conv2D(128,(3,3),activation='relu'))\nmodel2.add(layers.MaxPooling2D((2,2)))\nmodel2.add(layers.Flatten())\nmodel2.add(layers.Dropout(0.5))\nmodel2.add(layers.Dense(512,activation='relu'))\nmodel2.add(layers.Dense(1,activation='sigmoid'))","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:30:31.204517Z","iopub.execute_input":"2024-02-16T20:30:31.204870Z","iopub.status.idle":"2024-02-16T20:30:31.308492Z","shell.execute_reply.started":"2024-02-16T20:30:31.204844Z","shell.execute_reply":"2024-02-16T20:30:31.307569Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2.compile(loss='binary_crossentropy',optimizer=optimizers.RMSprop(lr=1e-4),metrics=['acc'])","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:30:32.315779Z","iopub.execute_input":"2024-02-16T20:30:32.316159Z","iopub.status.idle":"2024-02-16T20:30:32.328453Z","shell.execute_reply.started":"2024-02-16T20:30:32.316118Z","shell.execute_reply":"2024-02-16T20:30:32.327459Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"td=idg(rescale=1./255,\n                           rotation_range=40,\n                           width_shift_range=0.2,\n                           height_shift_range=0.2,\n                           shear_range=0.2,\n                           zoom_range=0.2,\n                           horizontal_flip=True,fill_mode='nearest'\n                          )\nted=idg(rescale=1./255)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:33:04.481378Z","iopub.execute_input":"2024-02-16T20:33:04.482228Z","iopub.status.idle":"2024-02-16T20:33:04.487298Z","shell.execute_reply.started":"2024-02-16T20:33:04.482194Z","shell.execute_reply":"2024-02-16T20:33:04.486249Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_g=td.flow_from_directory(tdir,target_size=(150,150),batch_size=20,class_mode='binary')\nvalidation_g=ted.flow_from_directory(vdir,target_size=(150,150),batch_size=20,class_mode='binary')","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:41:36.237382Z","iopub.execute_input":"2024-02-16T20:41:36.237750Z","iopub.status.idle":"2024-02-16T20:41:36.332379Z","shell.execute_reply.started":"2024-02-16T20:41:36.237720Z","shell.execute_reply":"2024-02-16T20:41:36.331510Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history2=model2.fit(train_g,steps_per_epoch=100,epochs=30,validation_data=validation_g,validation_steps=50)","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:42:36.988911Z","iopub.execute_input":"2024-02-16T20:42:36.989695Z","iopub.status.idle":"2024-02-16T20:49:03.062361Z","shell.execute_reply.started":"2024-02-16T20:42:36.989661Z","shell.execute_reply":"2024-02-16T20:49:03.061545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model2.save('second')","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:49:03.141022Z","iopub.execute_input":"2024-02-16T20:49:03.141338Z","iopub.status.idle":"2024-02-16T20:49:04.275411Z","shell.execute_reply.started":"2024-02-16T20:49:03.141313Z","shell.execute_reply":"2024-02-16T20:49:04.274580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nacc=history2.history['acc']\nval_acc=history2.history['val_acc']\nloss=history2.history['loss']\nval_loss=history2.history['val_loss']\n\nepochs=range(1,len(acc)+1)\n\nplt.plot(epochs,acc,'bo')\nplt.plot(epochs,val_acc,'bo')\nplt.legend()\n\nplt.figure()\n\nplt.plot(epochs,loss,'bo')\nplt.plot(epochs,val_loss,'bo')\nplt.legend()\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-02-16T20:50:38.903660Z","iopub.execute_input":"2024-02-16T20:50:38.904435Z","iopub.status.idle":"2024-02-16T20:50:39.230263Z","shell.execute_reply.started":"2024-02-16T20:50:38.904401Z","shell.execute_reply":"2024-02-16T20:50:39.229425Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}