{"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-26T16:42:13.397558Z","iopub.execute_input":"2021-07-26T16:42:13.398158Z","iopub.status.idle":"2021-07-26T16:42:13.403795Z","shell.execute_reply.started":"2021-07-26T16:42:13.398025Z","shell.execute_reply":"2021-07-26T16:42:13.402503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs-vs-cats","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:13.405758Z","iopub.execute_input":"2021-07-26T16:42:13.406252Z","iopub.status.idle":"2021-07-26T16:42:14.123264Z","shell.execute_reply.started":"2021-07-26T16:42:13.406205Z","shell.execute_reply":"2021-07-26T16:42:14.122107Z"},"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-26T16:42:14.125494Z","iopub.execute_input":"2021-07-26T16:42:14.125881Z","iopub.status.idle":"2021-07-26T16:42:21.243900Z","shell.execute_reply.started":"2021-07-26T16:42:14.125838Z","shell.execute_reply":"2021-07-26T16:42:21.243021Z"},"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-26T16:42:21.245464Z","iopub.execute_input":"2021-07-26T16:42:21.245857Z","iopub.status.idle":"2021-07-26T16:42:32.588092Z","shell.execute_reply.started":"2021-07-26T16:42:21.245817Z","shell.execute_reply":"2021-07-26T16:42:32.587288Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd dogs-vs-cats/train","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:32.589569Z","iopub.execute_input":"2021-07-26T16:42:32.589915Z","iopub.status.idle":"2021-07-26T16:42:32.597829Z","shell.execute_reply.started":"2021-07-26T16:42:32.589880Z","shell.execute_reply":"2021-07-26T16:42:32.596845Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir cats","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:32.599408Z","iopub.execute_input":"2021-07-26T16:42:32.599733Z","iopub.status.idle":"2021-07-26T16:42:33.274891Z","shell.execute_reply.started":"2021-07-26T16:42:32.599700Z","shell.execute_reply":"2021-07-26T16:42:33.273839Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:33.278185Z","iopub.execute_input":"2021-07-26T16:42:33.278494Z","iopub.status.idle":"2021-07-26T16:42:33.979336Z","shell.execute_reply.started":"2021-07-26T16:42:33.278465Z","shell.execute_reply":"2021-07-26T16:42:33.978196Z"},"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-26T16:42:33.982148Z","iopub.execute_input":"2021-07-26T16:42:33.982489Z","iopub.status.idle":"2021-07-26T16:42:33.988416Z","shell.execute_reply.started":"2021-07-26T16:42:33.982452Z","shell.execute_reply":"2021-07-26T16:42:33.987618Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"move_glob('./dogs', 'dog*.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:33.990091Z","iopub.execute_input":"2021-07-26T16:42:33.990912Z","iopub.status.idle":"2021-07-26T16:42:34.642523Z","shell.execute_reply.started":"2021-07-26T16:42:33.990874Z","shell.execute_reply":"2021-07-26T16:42:34.641659Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"move_glob('./cats', 'cat*.jpg')","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:34.643905Z","iopub.execute_input":"2021-07-26T16:42:34.644234Z","iopub.status.idle":"2021-07-26T16:42:35.081618Z","shell.execute_reply.started":"2021-07-26T16:42:34.644199Z","shell.execute_reply":"2021-07-26T16:42:35.080806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:35.082959Z","iopub.execute_input":"2021-07-26T16:42:35.083340Z","iopub.status.idle":"2021-07-26T16:42:35.088678Z","shell.execute_reply.started":"2021-07-26T16:42:35.083300Z","shell.execute_reply":"2021-07-26T16:42:35.087881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir valid","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:35.089958Z","iopub.execute_input":"2021-07-26T16:42:35.090511Z","iopub.status.idle":"2021-07-26T16:42:35.854973Z","shell.execute_reply.started":"2021-07-26T16:42:35.090475Z","shell.execute_reply":"2021-07-26T16:42:35.853831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd valid","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:35.859773Z","iopub.execute_input":"2021-07-26T16:42:35.861828Z","iopub.status.idle":"2021-07-26T16:42:35.874980Z","shell.execute_reply.started":"2021-07-26T16:42:35.861782Z","shell.execute_reply":"2021-07-26T16:42:35.872400Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir dogs","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:35.896320Z","iopub.execute_input":"2021-07-26T16:42:35.905972Z","iopub.status.idle":"2021-07-26T16:42:36.636956Z","shell.execute_reply.started":"2021-07-26T16:42:35.905915Z","shell.execute_reply":"2021-07-26T16:42:36.635895Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mkdir cats","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:36.640268Z","iopub.execute_input":"2021-07-26T16:42:36.640544Z","iopub.status.idle":"2021-07-26T16:42:37.274659Z","shell.execute_reply.started":"2021-07-26T16:42:36.640517Z","shell.execute_reply":"2021-07-26T16:42:37.273699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:37.277924Z","iopub.execute_input":"2021-07-26T16:42:37.278205Z","iopub.status.idle":"2021-07-26T16:42:37.283185Z","shell.execute_reply.started":"2021-07-26T16:42:37.278177Z","shell.execute_reply":"2021-07-26T16:42:37.282417Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"cd ../","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:42:37.284458Z","iopub.execute_input":"2021-07-26T16:42:37.285006Z","iopub.status.idle":"2021-07-26T16:42:37.294994Z","shell.execute_reply.started":"2021-07-26T16:42:37.284972Z","shell.execute_reply":"2021-07-26T16:42:37.294215Z"},"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-26T16:42:37.297847Z","iopub.execute_input":"2021-07-26T16:42:37.298181Z","iopub.status.idle":"2021-07-26T16:42:37.427917Z","shell.execute_reply.started":"2021-07-26T16:42:37.298157Z","shell.execute_reply":"2021-07-26T16:42:37.427201Z"},"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-26T16:42:37.428932Z","iopub.execute_input":"2021-07-26T16:42:37.429267Z","iopub.status.idle":"2021-07-26T16:43:50.820708Z","shell.execute_reply.started":"2021-07-26T16:42:37.429211Z","shell.execute_reply":"2021-07-26T16:43:50.819377Z"},"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-26T16:43:50.825947Z","iopub.execute_input":"2021-07-26T16:43:50.826667Z","iopub.status.idle":"2021-07-26T16:43:50.843191Z","shell.execute_reply.started":"2021-07-26T16:43:50.826601Z","shell.execute_reply":"2021-07-26T16:43:50.842267Z"},"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-26T16:43:50.844805Z","iopub.execute_input":"2021-07-26T16:43:50.845208Z","iopub.status.idle":"2021-07-26T16:45:34.620287Z","shell.execute_reply.started":"2021-07-26T16:43:50.845168Z","shell.execute_reply":"2021-07-26T16:45:34.619328Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for num in range(2500):\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-26T16:45:34.621581Z","iopub.execute_input":"2021-07-26T16:45:34.621896Z","iopub.status.idle":"2021-07-26T16:45:34.852620Z","shell.execute_reply.started":"2021-07-26T16:45:34.621863Z","shell.execute_reply":"2021-07-26T16:45:34.851834Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.preprocessing.image import ImageDataGenerator","metadata":{"execution":{"iopub.status.busy":"2021-07-26T16:45:34.857154Z","iopub.execute_input":"2021-07-26T16:45:34.857515Z","iopub.status.idle":"2021-07-26T16:45:40.060581Z","shell.execute_reply.started":"2021-07-26T16:45:34.857479Z","shell.execute_reply":"2021-07-26T16:45:40.059615Z"},"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-26T16:45:40.080805Z","iopub.execute_input":"2021-07-26T16:45:40.081144Z","iopub.status.idle":"2021-07-26T16:45:42.659135Z","shell.execute_reply.started":"2021-07-26T16:45:40.081109Z","shell.execute_reply":"2021-07-26T16:45:42.655444Z"},"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-26T16:45:42.660598Z","iopub.execute_input":"2021-07-26T16:45:42.660957Z","iopub.status.idle":"2021-07-26T16:45:42.666041Z","shell.execute_reply.started":"2021-07-26T16:45:42.660910Z","shell.execute_reply":"2021-07-26T16:45:42.664993Z"},"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 = 20000 / 32,validation_steps = 5000/32)","metadata":{"execution":{"iopub.status.busy":"2021-07-26T19:53:27.896083Z","iopub.execute_input":"2021-07-26T19:53:27.896474Z","iopub.status.idle":"2021-07-26T23:38:30.360811Z","shell.execute_reply.started":"2021-07-26T19:53:27.896436Z","shell.execute_reply":"2021-07-26T23:38:30.359977Z"},"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-27T00:14:43.685074Z","iopub.execute_input":"2021-07-27T00:14:43.685482Z","iopub.status.idle":"2021-07-27T00:14:43.738830Z","shell.execute_reply.started":"2021-07-27T00:14:43.685447Z","shell.execute_reply":"2021-07-27T00:14:43.737892Z"},"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-27T00:21:11.859277Z","iopub.execute_input":"2021-07-27T00:21:11.859610Z","iopub.status.idle":"2021-07-27T00:21:12.347275Z","shell.execute_reply.started":"2021-07-27T00:21:11.859582Z","shell.execute_reply":"2021-07-27T00:21:12.346405Z"},"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-27T00:21:22.050090Z","iopub.execute_input":"2021-07-27T00:21:22.050459Z","iopub.status.idle":"2021-07-27T00:21:22.237192Z","shell.execute_reply.started":"2021-07-27T00:21:22.050426Z","shell.execute_reply":"2021-07-27T00:21:22.236223Z"},"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-27T00:21:29.278985Z","iopub.execute_input":"2021-07-27T00:21:29.279412Z","iopub.status.idle":"2021-07-27T00:21:29.436749Z","shell.execute_reply.started":"2021-07-27T00:21:29.279364Z","shell.execute_reply":"2021-07-27T00:21:29.435625Z"},"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-27T00:21:34.549893Z","iopub.execute_input":"2021-07-27T00:21:34.550278Z","iopub.status.idle":"2021-07-27T00:21:34.672334Z","shell.execute_reply.started":"2021-07-27T00:21:34.550220Z","shell.execute_reply":"2021-07-27T00:21:34.671407Z"},"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-27T00:21:38.786250Z","iopub.execute_input":"2021-07-27T00:21:38.786634Z","iopub.status.idle":"2021-07-27T00:22:29.132386Z","shell.execute_reply.started":"2021-07-27T00:21:38.786600Z","shell.execute_reply":"2021-07-27T00:22:29.131498Z"},"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-27T00:22:34.278998Z","iopub.execute_input":"2021-07-27T00:22:34.279369Z","iopub.status.idle":"2021-07-27T00:22:34.288158Z","shell.execute_reply.started":"2021-07-27T00:22:34.279332Z","shell.execute_reply":"2021-07-27T00:22:34.285132Z"},"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-27T00:22:37.222121Z","iopub.execute_input":"2021-07-27T00:22:37.224429Z"},"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":[]}]}