{"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":"##ここから","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:15.932499Z","iopub.execute_input":"2021-07-28T13:01:15.933034Z","iopub.status.idle":"2021-07-28T13:01:15.938499Z","shell.execute_reply.started":"2021-07-28T13:01:15.932941Z","shell.execute_reply":"2021-07-28T13:01:15.937522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs-vs-cats","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:15.94063Z","iopub.execute_input":"2021-07-28T13:01:15.941311Z","iopub.status.idle":"2021-07-28T13:01:16.592897Z","shell.execute_reply.started":"2021-07-28T13:01:15.941274Z","shell.execute_reply":"2021-07-28T13:01:16.591845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import zipfile\nwith zipfile.ZipFile('../input/dogs-vs-cats-redux-kernels-edition/test.zip') as existing_zip:\n    existing_zip.extractall('./dogs-vs-cats')","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:16.594618Z","iopub.execute_input":"2021-07-28T13:01:16.594899Z","iopub.status.idle":"2021-07-28T13:01:23.085275Z","shell.execute_reply.started":"2021-07-28T13:01:16.594863Z","shell.execute_reply":"2021-07-28T13:01:23.084352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import zipfile\nwith zipfile.ZipFile('../input/dogs-vs-cats-redux-kernels-edition/train.zip') as existing_zip:\n    existing_zip.extractall('./dogs-vs-cats')","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:23.08687Z","iopub.execute_input":"2021-07-28T13:01:23.087191Z","iopub.status.idle":"2021-07-28T13:01:33.82051Z","shell.execute_reply.started":"2021-07-28T13:01:23.087153Z","shell.execute_reply":"2021-07-28T13:01:33.819646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd dogs-vs-cats/train","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:33.823958Z","iopub.execute_input":"2021-07-28T13:01:33.824259Z","iopub.status.idle":"2021-07-28T13:01:33.832735Z","shell.execute_reply.started":"2021-07-28T13:01:33.82422Z","shell.execute_reply":"2021-07-28T13:01:33.831684Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir cats","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:33.834413Z","iopub.execute_input":"2021-07-28T13:01:33.834807Z","iopub.status.idle":"2021-07-28T13:01:34.505457Z","shell.execute_reply.started":"2021-07-28T13:01:33.834769Z","shell.execute_reply":"2021-07-28T13:01:34.504301Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:34.507245Z","iopub.execute_input":"2021-07-28T13:01:34.507646Z","iopub.status.idle":"2021-07-28T13:01:35.174218Z","shell.execute_reply.started":"2021-07-28T13:01:34.507604Z","shell.execute_reply":"2021-07-28T13:01:35.173208Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import shutil\nimport glob\nimport os\n\ndef move_glob(dst_path, pathname, recursive=True):\n    for p in glob.glob(pathname, recursive=recursive):\n        shutil.move(p, dst_path)","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:35.177332Z","iopub.execute_input":"2021-07-28T13:01:35.177686Z","iopub.status.idle":"2021-07-28T13:01:35.183992Z","shell.execute_reply.started":"2021-07-28T13:01:35.17765Z","shell.execute_reply":"2021-07-28T13:01:35.181979Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"move_glob('./dogs', 'dog*.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:35.186071Z","iopub.execute_input":"2021-07-28T13:01:35.186462Z","iopub.status.idle":"2021-07-28T13:01:35.676315Z","shell.execute_reply.started":"2021-07-28T13:01:35.186428Z","shell.execute_reply":"2021-07-28T13:01:35.675377Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"move_glob('./cats', 'cat*.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:35.679909Z","iopub.execute_input":"2021-07-28T13:01:35.68024Z","iopub.status.idle":"2021-07-28T13:01:36.135563Z","shell.execute_reply.started":"2021-07-28T13:01:35.68018Z","shell.execute_reply":"2021-07-28T13:01:36.134583Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:36.137994Z","iopub.execute_input":"2021-07-28T13:01:36.138268Z","iopub.status.idle":"2021-07-28T13:01:36.147789Z","shell.execute_reply.started":"2021-07-28T13:01:36.138242Z","shell.execute_reply":"2021-07-28T13:01:36.14589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir valid","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:36.149135Z","iopub.execute_input":"2021-07-28T13:01:36.149538Z","iopub.status.idle":"2021-07-28T13:01:36.819467Z","shell.execute_reply.started":"2021-07-28T13:01:36.149504Z","shell.execute_reply":"2021-07-28T13:01:36.818196Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd valid","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:36.821038Z","iopub.execute_input":"2021-07-28T13:01:36.821407Z","iopub.status.idle":"2021-07-28T13:01:36.82923Z","shell.execute_reply.started":"2021-07-28T13:01:36.821369Z","shell.execute_reply":"2021-07-28T13:01:36.828285Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:36.830565Z","iopub.execute_input":"2021-07-28T13:01:36.830903Z","iopub.status.idle":"2021-07-28T13:01:37.62334Z","shell.execute_reply.started":"2021-07-28T13:01:36.830868Z","shell.execute_reply":"2021-07-28T13:01:37.622147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir cats","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:37.624791Z","iopub.execute_input":"2021-07-28T13:01:37.625093Z","iopub.status.idle":"2021-07-28T13:01:38.299912Z","shell.execute_reply.started":"2021-07-28T13:01:37.625063Z","shell.execute_reply":"2021-07-28T13:01:38.298824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:38.301463Z","iopub.execute_input":"2021-07-28T13:01:38.301843Z","iopub.status.idle":"2021-07-28T13:01:38.309928Z","shell.execute_reply.started":"2021-07-28T13:01:38.301801Z","shell.execute_reply":"2021-07-28T13:01:38.308945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:38.311463Z","iopub.execute_input":"2021-07-28T13:01:38.311834Z","iopub.status.idle":"2021-07-28T13:01:38.322984Z","shell.execute_reply.started":"2021-07-28T13:01:38.311763Z","shell.execute_reply":"2021-07-28T13:01:38.322138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nimport numpy as np\n\ndef resizehalf(src_file, dst_file):\n    src_img = cv2.imread(src_file)\n    h, w, c = src_img.shape\n\n    #比率設定\n    scale_w = 1 / 2\n    scale_h = 1 / 2\n\n    resize_img = cv2.resize(src_img, dsize=None, fx=scale_w, fy=scale_w, interpolation = cv2.INTER_AREA)\n\n    # dst_img 生成\n    dst_img = np.zeros((h//2 + h%2, w//2 + w%2, 3), dtype = np.uint8)\n\n    # dst_imgにresize_imgを合成\n    h, w, c = resize_img.shape\n    dst_img[0:h, 0:w] = resize_img\n\n    cv2.imwrite(dst_file, dst_img)","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:38.324659Z","iopub.execute_input":"2021-07-28T13:01:38.325298Z","iopub.status.idle":"2021-07-28T13:01:38.491093Z","shell.execute_reply.started":"2021-07-28T13:01:38.325262Z","shell.execute_reply":"2021-07-28T13:01:38.490169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for num in range(0, 12500):\n    resizehalf('./dogs-vs-cats/train/dogs/dog.' + str(num) + '.jpg', './dogs-vs-cats/train/dogs/dog.' + str(num+12500) + '.jpg')\n    resizehalf('./dogs-vs-cats/train/cats/cat.' + str(num) + '.jpg', './dogs-vs-cats/train/cats/cat.' + str(num+12500) + '.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:01:38.493358Z","iopub.execute_input":"2021-07-28T13:01:38.493638Z","iopub.status.idle":"2021-07-28T13:02:53.459277Z","shell.execute_reply.started":"2021-07-28T13:01:38.493611Z","shell.execute_reply":"2021-07-28T13:02:53.458397Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nimport numpy as np\n\ndef resize(src_file, dst_file, width, height):\n    \"\"\"\n    画像ファイルを与えられたサイズにサイズ変換する関数\n    アス比は固定、左上に寄せる、余った部分はゼロで埋める\n\n    Returns\n    -------\n    ret_scale : float\n    拡大/縮小した倍率\n    \"\"\"\n\n    src_img = cv2.imread(src_file)\n    h, w, c = src_img.shape\n    # dst_img = cv2.resize(src_img, dsize=(width, height))\n\n    # アス比固定, padding\n    scale_w = width / w\n    scale_h = height / h\n\n    ret_scale = 1.0\n    # Down Convert\n    if(scale_w < 1.0 or scale_h < 1.0):\n        if(scale_w < scale_h): \n            resize_img = cv2.resize(src_img, dsize=None, fx=scale_w, fy=scale_w, interpolation = cv2.INTER_AREA)\n            ret_scale = scale_w\n        else:\n            resize_img = cv2.resize(src_img, dsize=None, fx=scale_h, fy=scale_h, interpolation = cv2.INTER_AREA)\n            ret_scale = scale_h\n    else:\n        resize_img = src_img\n\n    # dst_img 生成\n    dst_img = np.zeros((height, width, 3), dtype = np.uint8)\n\n    # dst_imgにresize_imgを合成\n    top = 0\n    left = 0\n    #dst_img[top:height + top, left:width + left] = resize_img\n    h, w, c = resize_img.shape\n    dst_img[0:h, 0:w] = resize_img\n\n    cv2.imwrite(dst_file, dst_img)\n\n    return ret_scale","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:02:53.460557Z","iopub.execute_input":"2021-07-28T13:02:53.460888Z","iopub.status.idle":"2021-07-28T13:02:53.47285Z","shell.execute_reply.started":"2021-07-28T13:02:53.460855Z","shell.execute_reply":"2021-07-28T13:02:53.472057Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for num in range(0, 12500):\n    resize('./dogs-vs-cats/train/dogs/dog.' + str(num) + '.jpg', './dogs-vs-cats/train/dogs/dog.' + str(num) + '.jpg', 216, 216)\n    resize('./dogs-vs-cats/train/cats/cat.' + str(num) + '.jpg', './dogs-vs-cats/train/cats/cat.' + str(num) + '.jpg', 216, 216)","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:02:53.47407Z","iopub.execute_input":"2021-07-28T13:02:53.474488Z","iopub.status.idle":"2021-07-28T13:04:34.94498Z","shell.execute_reply.started":"2021-07-28T13:02:53.47442Z","shell.execute_reply":"2021-07-28T13:04:34.944006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for num in range(5000):\n    move_glob('./dogs-vs-cats/valid/cats', './dogs-vs-cats/train/cats/cat.'+ str(num) +'.jpg')\n    move_glob('./dogs-vs-cats/valid/dogs', './dogs-vs-cats/train/dogs/dog.'+ str(num) +'.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:04:34.946436Z","iopub.execute_input":"2021-07-28T13:04:34.946924Z","iopub.status.idle":"2021-07-28T13:04:35.398605Z","shell.execute_reply.started":"2021-07-28T13:04:34.94688Z","shell.execute_reply":"2021-07-28T13:04:35.397711Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.preprocessing.image import ImageDataGenerator","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:04:35.402367Z","iopub.execute_input":"2021-07-28T13:04:35.402668Z","iopub.status.idle":"2021-07-28T13:04:40.88905Z","shell.execute_reply.started":"2021-07-28T13:04:35.402636Z","shell.execute_reply":"2021-07-28T13:04:40.888042Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_dir = './dogs-vs-cats/train'\nvalid_data_dir = './dogs-vs-cats/valid'\n\ntrain_datagen = ImageDataGenerator(rescale = 1.0/255)\nvalid_datagen = ImageDataGenerator(rescale = 1.0/255)\n\ntrain_generator = train_datagen.flow_from_directory(directory = train_data_dir,target_size = (216, 216),batch_size = 32, class_mode = \"binary\")\nvalid_generator = valid_datagen.flow_from_directory(directory = valid_data_dir,target_size = (216, 216),batch_size = 32, class_mode = \"binary\")","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:04:40.89087Z","iopub.execute_input":"2021-07-28T13:04:40.89126Z","iopub.status.idle":"2021-07-28T13:04:43.378921Z","shell.execute_reply.started":"2021-07-28T13:04:40.891228Z","shell.execute_reply":"2021-07-28T13:04:43.378046Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import keras\nfrom keras.models import Sequential\nfrom keras.layers import Dense,Flatten\nfrom keras.layers import Conv2D,MaxPooling2D,Dropout\nfrom keras import optimizers","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:04:43.380176Z","iopub.execute_input":"2021-07-28T13:04:43.380706Z","iopub.status.idle":"2021-07-28T13:04:43.385533Z","shell.execute_reply.started":"2021-07-28T13:04:43.380667Z","shell.execute_reply":"2021-07-28T13:04:43.384702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = Sequential()\n\nmodel.add(Conv2D(64,kernel_size = (5,5),activation = \"relu\",input_shape = (216,216,3)))\n\nmodel.add(MaxPooling2D(pool_size = (2,2)))\n\nmodel.add(Conv2D(128,kernel_size = (5,5),activation = \"relu\"))\nmodel.add(MaxPooling2D(pool_size = (2,2)))\nmodel.add(Conv2D(128,kernel_size = (5,5),activation = \"relu\"))\nmodel.add(MaxPooling2D(pool_size = (2,2)))\nmodel.add(Conv2D(128,kernel_size = (5,5),activation = \"relu\"))\nmodel.add(MaxPooling2D(pool_size = (2,2)))\nmodel.add(Dropout(0.5))\nmodel.add(Flatten())\nmodel.add(Dense(256,activation = \"relu\"))\nmodel.add(Dropout(0.25))\nmodel.add(Dense(1,activation = \"sigmoid\"))\n\nsgd = optimizers.SGD(lr = 0.1)\n\nmodel.compile(loss = \"mean_squared_error\",optimizer = sgd,metrics = [\"accuracy\"])\nhistory = model.fit_generator(train_generator,epochs = 30,verbose = 1, validation_data = (valid_generator), steps_per_epoch = 40000 / 32,validation_steps = 10000/32)","metadata":{"execution":{"iopub.status.busy":"2021-07-28T13:04:43.386814Z","iopub.execute_input":"2021-07-28T13:04:43.387409Z","iopub.status.idle":"2021-07-28T20:35:10.084737Z","shell.execute_reply.started":"2021-07-28T13:04:43.387373Z","shell.execute_reply":"2021-07-28T20:35:10.083715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.save(\"./dogs-vs-cats/dogs-vs-cats_model.hdf5\")","metadata":{"execution":{"iopub.status.busy":"2021-07-28T20:35:10.088353Z","iopub.execute_input":"2021-07-28T20:35:10.088669Z","iopub.status.idle":"2021-07-28T20:35:10.138433Z","shell.execute_reply.started":"2021-07-28T20:35:10.088637Z","shell.execute_reply":"2021-07-28T20:35:10.13757Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.utils import plot_model\nmodel.summary()\nplot_model(model,to_file='./model1.png')","metadata":{"execution":{"iopub.status.busy":"2021-07-28T20:35:10.139663Z","iopub.execute_input":"2021-07-28T20:35:10.140013Z","iopub.status.idle":"2021-07-28T20:35:10.627297Z","shell.execute_reply.started":"2021-07-28T20:35:10.139977Z","shell.execute_reply":"2021-07-28T20:35:10.626322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\nloss = history.history[\"loss\"]\nval_loss = history.history[\"val_loss\"]\n\nlearning_count = len(loss)+1\n\nplt.plot(range(1,learning_count),loss,marker = \"+\",label = \"loss\")\nplt.plot(range(1,learning_count),val_loss,marker = \"+\",label = \"val_loss\")\nplt.legend(loc = \"best\",fontsize = 10)\nplt.xlabel(\"learning_count\")\nplt.ylabel(\"loss\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-07-28T20:35:10.629093Z","iopub.execute_input":"2021-07-28T20:35:10.62951Z","iopub.status.idle":"2021-07-28T20:35:10.800009Z","shell.execute_reply.started":"2021-07-28T20:35:10.629467Z","shell.execute_reply":"2021-07-28T20:35:10.79899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"accuracy = history.history[\"accuracy\"]\nval_accuracy = history.history[\"val_accuracy\"]\n\nlearning_count = len(loss)+1\n\nplt.plot(range(1,learning_count),accuracy,marker = \"+\",label = \"accuracy\")\nplt.plot(range(1,learning_count),val_accuracy,marker = \"+\",label = \"val_accuracy\")\nplt.legend(loc = \"best\",fontsize = 10)\nplt.xlabel(\"learning_count\")\nplt.ylabel(\"accuracy\")\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-07-28T20:35:10.801589Z","iopub.execute_input":"2021-07-28T20:35:10.801986Z","iopub.status.idle":"2021-07-28T20:35:10.965191Z","shell.execute_reply.started":"2021-07-28T20:35:10.801944Z","shell.execute_reply":"2021-07-28T20:35:10.964258Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.models import load_model\nnew_model = load_model('./dogs-vs-cats/dogs-vs-cats_model.hdf5')","metadata":{"execution":{"iopub.status.busy":"2021-07-28T20:35:10.966644Z","iopub.execute_input":"2021-07-28T20:35:10.967052Z","iopub.status.idle":"2021-07-28T20:35:11.089501Z","shell.execute_reply.started":"2021-07-28T20:35:10.967012Z","shell.execute_reply":"2021-07-28T20:35:11.088663Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for num in range(1, 12501):\n    resize('./dogs-vs-cats/test/' + str(num) + '.jpg', './dogs-vs-cats/test/' + str(num) + '.jpg', 216, 216)","metadata":{"execution":{"iopub.status.busy":"2021-07-28T20:35:11.090741Z","iopub.execute_input":"2021-07-28T20:35:11.091275Z","iopub.status.idle":"2021-07-28T20:36:02.140724Z","shell.execute_reply.started":"2021-07-28T20:35:11.091229Z","shell.execute_reply":"2021-07-28T20:36:02.139811Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"result_num = []\n\nfor num in range(1, 12501):\n    result_num.append(num)","metadata":{"execution":{"iopub.status.busy":"2021-07-28T20:36:02.141991Z","iopub.execute_input":"2021-07-28T20:36:02.142358Z","iopub.status.idle":"2021-07-28T20:36:02.149791Z","shell.execute_reply.started":"2021-07-28T20:36:02.142322Z","shell.execute_reply":"2021-07-28T20:36:02.148913Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#100枚までの結果出力\nfrom skimage import io\nimport numpy as np\nfrom skimage.transform import resize\nfrom keras.preprocessing.image import load_img, img_to_array\nresult = []\n\n%matplotlib inline\n\n#./train1/cats/cat.\n#./test/\nfor num in range(1, 12501):\n    img = io.imread('./dogs-vs-cats/test/'+ str(num) +'.jpg')\n    io.imshow(img)\n\n    # 判定する画像の読み込み\n    image_infer = load_img('./dogs-vs-cats/test/'+ str(num) +'.jpg', target_size=(216, 216))\n    data_infer = img_to_array(image_infer)\n    data_infer = np.expand_dims(data_infer, axis=0)\n    data_infer = data_infer / 255.0\n\n    # 判定処理の実行\n    model.load_weights(os.path.join('./dogs-vs-cats/', 'dogs-vs-cats_model.hdf5'))\n    result_predict = model.predict(data_infer)[0] * 100\n    result.append(result_predict)\n    if num % 100 == 0:\n        print(num,'：Dog (%.1f%%)' % result_predict)\n\n    # 判定結果の出力\n    #if result[0] > result[1]:\n    #    print('Cat (%.1f%%)' % result[0])\n    #else:\n    #print(num,'：Dog (%.1f%%)' % result_predict)","metadata":{"execution":{"iopub.status.busy":"2021-07-28T20:36:02.151167Z","iopub.execute_input":"2021-07-28T20:36:02.151546Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import csv\nimport pandas as pd\ndf = pd.DataFrame([result])\ndf = df.T\nfor col in df:\n    df[col]=df[col].astype(str).str.replace(\"[\",\"\").str.replace(\"]\",\"\")\n\ndf.to_csv(\"./sample_submission.csv\", index=False)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}