{"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":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2021-05-23T11:20:43.866562Z","iopub.execute_input":"2021-05-23T11:20:43.867059Z","iopub.status.idle":"2021-05-23T11:20:43.877877Z","shell.execute_reply.started":"2021-05-23T11:20:43.866948Z","shell.execute_reply":"2021-05-23T11:20:43.876864Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#libraries\nimport numpy as np\nimport pandas as pd\n\nimport matplotlib.pyplot as plt\n\nimport tensorflow as tf\nfrom tensorflow import keras\nfrom keras import layers,models","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:43.879429Z","iopub.execute_input":"2021-05-23T11:20:43.879812Z","iopub.status.idle":"2021-05-23T11:20:50.390557Z","shell.execute_reply.started":"2021-05-23T11:20:43.879770Z","shell.execute_reply":"2021-05-23T11:20:50.389746Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv('/kaggle/input/digit-recognizer/train.csv')\ndf_test = pd.read_csv('/kaggle/input/digit-recognizer/test.csv')","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:50.394743Z","iopub.execute_input":"2021-05-23T11:20:50.395719Z","iopub.status.idle":"2021-05-23T11:20:55.763617Z","shell.execute_reply.started":"2021-05-23T11:20:50.395660Z","shell.execute_reply":"2021-05-23T11:20:55.762807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.shape","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:55.765284Z","iopub.execute_input":"2021-05-23T11:20:55.765900Z","iopub.status.idle":"2021-05-23T11:20:55.775399Z","shell.execute_reply.started":"2021-05-23T11:20:55.765834Z","shell.execute_reply":"2021-05-23T11:20:55.773951Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_test.head()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:55.776640Z","iopub.execute_input":"2021-05-23T11:20:55.777036Z","iopub.status.idle":"2021-05-23T11:20:55.819014Z","shell.execute_reply.started":"2021-05-23T11:20:55.776920Z","shell.execute_reply":"2021-05-23T11:20:55.817686Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels = df_train['label']\ndata = df_train.drop(columns=['label'])","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:55.820293Z","iopub.execute_input":"2021-05-23T11:20:55.820750Z","iopub.status.idle":"2021-05-23T11:20:55.946822Z","shell.execute_reply.started":"2021-05-23T11:20:55.820711Z","shell.execute_reply":"2021-05-23T11:20:55.945705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(data.shape,labels.shape,df_test.shape)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:55.950037Z","iopub.execute_input":"2021-05-23T11:20:55.950471Z","iopub.status.idle":"2021-05-23T11:20:55.958601Z","shell.execute_reply.started":"2021-05-23T11:20:55.950418Z","shell.execute_reply":"2021-05-23T11:20:55.957447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#reshaping the train and test data\ndata = data.values.reshape(-1,28,28,1)\ndf_test = df_test.values.reshape(-1,28,28,1)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:55.962207Z","iopub.execute_input":"2021-05-23T11:20:55.962734Z","iopub.status.idle":"2021-05-23T11:20:55.974372Z","shell.execute_reply.started":"2021-05-23T11:20:55.962681Z","shell.execute_reply":"2021-05-23T11:20:55.973262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(data.shape,df_test.shape)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:55.975522Z","iopub.execute_input":"2021-05-23T11:20:55.975968Z","iopub.status.idle":"2021-05-23T11:20:55.990870Z","shell.execute_reply.started":"2021-05-23T11:20:55.975935Z","shell.execute_reply":"2021-05-23T11:20:55.989771Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#normalizing the data\ndata = data/255.0\ndf_test = df_test/255.0","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:55.992200Z","iopub.execute_input":"2021-05-23T11:20:55.992787Z","iopub.status.idle":"2021-05-23T11:20:56.213944Z","shell.execute_reply.started":"2021-05-23T11:20:55.992752Z","shell.execute_reply":"2021-05-23T11:20:56.212896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#visualize some of data\n\nplt.figure(figsize=(10,10))\nfor i in range(25):\n    plt.subplot(5,5,i+1)\n    plt.xticks([])\n    plt.yticks([])\n    plt.imshow(data[i])\n    plt.xlabel(\"NUmber is {}\".format(labels[i]))","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:56.215127Z","iopub.execute_input":"2021-05-23T11:20:56.215425Z","iopub.status.idle":"2021-05-23T11:20:57.348727Z","shell.execute_reply.started":"2021-05-23T11:20:56.215398Z","shell.execute_reply":"2021-05-23T11:20:57.347595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels.value_counts().plot(kind='bar');","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:57.349945Z","iopub.execute_input":"2021-05-23T11:20:57.350350Z","iopub.status.idle":"2021-05-23T11:20:57.505906Z","shell.execute_reply.started":"2021-05-23T11:20:57.350314Z","shell.execute_reply":"2021-05-23T11:20:57.504992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#train_test_split\nfrom sklearn.model_selection import train_test_split\nx_train,x_test,y_train,y_test = train_test_split(data,labels,random_state=42,test_size=0.2)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:57.507043Z","iopub.execute_input":"2021-05-23T11:20:57.507534Z","iopub.status.idle":"2021-05-23T11:20:58.668365Z","shell.execute_reply.started":"2021-05-23T11:20:57.507493Z","shell.execute_reply":"2021-05-23T11:20:58.667344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(x_train.shape,y_train.shape)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:58.669508Z","iopub.execute_input":"2021-05-23T11:20:58.669789Z","iopub.status.idle":"2021-05-23T11:20:58.674523Z","shell.execute_reply.started":"2021-05-23T11:20:58.669760Z","shell.execute_reply":"2021-05-23T11:20:58.673615Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train.dtype","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:58.675771Z","iopub.execute_input":"2021-05-23T11:20:58.676151Z","iopub.status.idle":"2021-05-23T11:20:58.689408Z","shell.execute_reply.started":"2021-05-23T11:20:58.676118Z","shell.execute_reply":"2021-05-23T11:20:58.688429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Model","metadata":{}},{"cell_type":"code","source":"model = models.Sequential([\n    #cnn \n    layers.Conv2D(32,(3,3),activation='relu',input_shape=(28,28,1)),\n    layers.MaxPooling2D((2,2)),\n    \n    layers.Conv2D(64,(3,3),activation='relu'),\n    layers.MaxPooling2D((2,2)),\n    \n    layers.Conv2D(128,(3,3),activation='relu'),\n    layers.MaxPooling2D((2,2)),\n    \n    #dense layers\n    layers.Flatten(),\n    \n    layers.Dense(256,activation='relu'),\n    layers.Dropout(0.5),\n    \n    layers.Dense(128,activation='relu'),\n    layers.Dropout(0.5),\n    \n    layers.Dense(64,activation='relu'),\n    layers.Dropout(0.5),\n    \n    layers.Dense(10,activation='softmax')\n])","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:58.692482Z","iopub.execute_input":"2021-05-23T11:20:58.692766Z","iopub.status.idle":"2021-05-23T11:20:58.863578Z","shell.execute_reply.started":"2021-05-23T11:20:58.692740Z","shell.execute_reply":"2021-05-23T11:20:58.862635Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#complie the model\nmodel.compile(loss='sparse_categorical_crossentropy',optimizer='adam',metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:58.865070Z","iopub.execute_input":"2021-05-23T11:20:58.865396Z","iopub.status.idle":"2021-05-23T11:20:58.882478Z","shell.execute_reply.started":"2021-05-23T11:20:58.865362Z","shell.execute_reply":"2021-05-23T11:20:58.881371Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.summary()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:58.883786Z","iopub.execute_input":"2021-05-23T11:20:58.884186Z","iopub.status.idle":"2021-05-23T11:20:58.896811Z","shell.execute_reply.started":"2021-05-23T11:20:58.884151Z","shell.execute_reply":"2021-05-23T11:20:58.895426Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#callback / early stopping\ncallback = tf.keras.callbacks.EarlyStopping(monitor='val_accuracy',patience=3)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:58.899959Z","iopub.execute_input":"2021-05-23T11:20:58.900297Z","iopub.status.idle":"2021-05-23T11:20:58.907197Z","shell.execute_reply.started":"2021-05-23T11:20:58.900263Z","shell.execute_reply":"2021-05-23T11:20:58.906230Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#training the model\nhist = model.fit(x_train,y_train,epochs=15,validation_split=0.1,callbacks=[callback])","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:20:58.908900Z","iopub.execute_input":"2021-05-23T11:20:58.909425Z","iopub.status.idle":"2021-05-23T11:23:35.162017Z","shell.execute_reply.started":"2021-05-23T11:20:58.909369Z","shell.execute_reply":"2021-05-23T11:23:35.160916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#testing the model\nmodel.evaluate(x_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:35.163587Z","iopub.execute_input":"2021-05-23T11:23:35.163974Z","iopub.status.idle":"2021-05-23T11:23:36.896953Z","shell.execute_reply.started":"2021-05-23T11:23:35.163899Z","shell.execute_reply":"2021-05-23T11:23:36.895794Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"> Some plots","metadata":{}},{"cell_type":"code","source":"#visualize the models accuray\nplt.plot(hist.history['accuracy'])\nplt.plot(hist.history['val_accuracy'])\nplt.title(\"Model Accuracy\")\nplt.ylabel(\"Accuracy\")\nplt.xlabel(\"Epoch\")\nplt.legend(['Train','Val'],loc='upper left')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:36.898461Z","iopub.execute_input":"2021-05-23T11:23:36.899146Z","iopub.status.idle":"2021-05-23T11:23:37.047588Z","shell.execute_reply.started":"2021-05-23T11:23:36.899100Z","shell.execute_reply":"2021-05-23T11:23:37.046356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#visualize models loss\nplt.plot(hist.history['loss'])\nplt.plot(hist.history['val_loss'])\nplt.title(\"Model Lossy\")\nplt.ylabel(\"Loss\")\nplt.xlabel(\"Epoch\")\nplt.legend(['Train','Val'],loc='upper right')\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:37.048731Z","iopub.execute_input":"2021-05-23T11:23:37.049013Z","iopub.status.idle":"2021-05-23T11:23:37.203687Z","shell.execute_reply.started":"2021-05-23T11:23:37.048986Z","shell.execute_reply":"2021-05-23T11:23:37.203014Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#classification report \nfrom sklearn.metrics import classification_report,confusion_matrix\n\ntest_pred = model.predict(x_test)\ntest_pred = [np.argmax(i) for i in test_pred]\n\nprint(classification_report(test_pred,y_test))","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:37.204658Z","iopub.execute_input":"2021-05-23T11:23:37.205085Z","iopub.status.idle":"2021-05-23T11:23:38.856591Z","shell.execute_reply.started":"2021-05-23T11:23:37.205044Z","shell.execute_reply":"2021-05-23T11:23:38.855415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#confusion matrix\nprint(confusion_matrix(test_pred,y_test))","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:38.858025Z","iopub.execute_input":"2021-05-23T11:23:38.858428Z","iopub.status.idle":"2021-05-23T11:23:38.876053Z","shell.execute_reply.started":"2021-05-23T11:23:38.858385Z","shell.execute_reply":"2021-05-23T11:23:38.874614Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_pred[:10]","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:38.877864Z","iopub.execute_input":"2021-05-23T11:23:38.878306Z","iopub.status.idle":"2021-05-23T11:23:38.885528Z","shell.execute_reply.started":"2021-05-23T11:23:38.878269Z","shell.execute_reply":"2021-05-23T11:23:38.884562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_test = np.array(y_test,'int32')","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:38.886985Z","iopub.execute_input":"2021-05-23T11:23:38.887259Z","iopub.status.idle":"2021-05-23T11:23:38.900500Z","shell.execute_reply.started":"2021-05-23T11:23:38.887233Z","shell.execute_reply":"2021-05-23T11:23:38.899196Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(15,10))\nfor i in range(25):\n    plt.subplot(5,5,i+1)\n    plt.xticks([])\n    plt.yticks([])\n    plt.imshow(x_test[i])\n    plt.xlabel(\"Actual: {}\".format(y_test[i]))\n    plt.ylabel(\"Predicted: {}\".format(test_pred[i]))","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:38.902011Z","iopub.execute_input":"2021-05-23T11:23:38.902451Z","iopub.status.idle":"2021-05-23T11:23:40.187092Z","shell.execute_reply.started":"2021-05-23T11:23:38.902398Z","shell.execute_reply":"2021-05-23T11:23:40.186147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### Final test data","metadata":{}},{"cell_type":"code","source":"final_pred = model.predict(df_test)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:40.188531Z","iopub.execute_input":"2021-05-23T11:23:40.188928Z","iopub.status.idle":"2021-05-23T11:23:45.088576Z","shell.execute_reply.started":"2021-05-23T11:23:40.188886Z","shell.execute_reply":"2021-05-23T11:23:45.087526Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_pred = [np.argmax(i) for i in final_pred]","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:45.090230Z","iopub.execute_input":"2021-05-23T11:23:45.090638Z","iopub.status.idle":"2021-05-23T11:23:45.147616Z","shell.execute_reply.started":"2021-05-23T11:23:45.090598Z","shell.execute_reply":"2021-05-23T11:23:45.146639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_pred[:10]","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:45.148988Z","iopub.execute_input":"2021-05-23T11:23:45.149409Z","iopub.status.idle":"2021-05-23T11:23:45.155883Z","shell.execute_reply.started":"2021-05-23T11:23:45.149364Z","shell.execute_reply":"2021-05-23T11:23:45.154906Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_format = pd.read_csv(\"/kaggle/input/digit-recognizer/sample_submission.csv\")\nsubmission_format.head()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:45.157350Z","iopub.execute_input":"2021-05-23T11:23:45.157813Z","iopub.status.idle":"2021-05-23T11:23:45.190825Z","shell.execute_reply.started":"2021-05-23T11:23:45.157773Z","shell.execute_reply":"2021-05-23T11:23:45.189891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(submission_format.ImageId)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:45.191995Z","iopub.execute_input":"2021-05-23T11:23:45.192272Z","iopub.status.idle":"2021-05-23T11:23:45.198607Z","shell.execute_reply.started":"2021-05-23T11:23:45.192242Z","shell.execute_reply":"2021-05-23T11:23:45.197430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_format.ImageId.nunique()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:45.199984Z","iopub.execute_input":"2021-05-23T11:23:45.200295Z","iopub.status.idle":"2021-05-23T11:23:45.218439Z","shell.execute_reply.started":"2021-05-23T11:23:45.200264Z","shell.execute_reply":"2021-05-23T11:23:45.217378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final_pred = pd.DataFrame(final_pred)\nfinal_pred.columns =['Label']","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:45.219631Z","iopub.execute_input":"2021-05-23T11:23:45.220063Z","iopub.status.idle":"2021-05-23T11:23:45.240683Z","shell.execute_reply.started":"2021-05-23T11:23:45.220027Z","shell.execute_reply":"2021-05-23T11:23:45.239691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final = pd.concat([pd.Series(range(1,28001),name=\"ImageId\"),final_pred],axis=1)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:45.241676Z","iopub.execute_input":"2021-05-23T11:23:45.241977Z","iopub.status.idle":"2021-05-23T11:23:45.256265Z","shell.execute_reply.started":"2021-05-23T11:23:45.241944Z","shell.execute_reply":"2021-05-23T11:23:45.255224Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"final.head()","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:23:45.257751Z","iopub.execute_input":"2021-05-23T11:23:45.258239Z","iopub.status.idle":"2021-05-23T11:23:45.273236Z","shell.execute_reply.started":"2021-05-23T11:23:45.258199Z","shell.execute_reply":"2021-05-23T11:23:45.271902Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"### using an outside image","metadata":{}},{"cell_type":"code","source":"from PIL import Image\nfrom PIL.Image import open","metadata":{"execution":{"iopub.status.busy":"2021-05-23T11:37:42.214717Z","iopub.execute_input":"2021-05-23T11:37:42.215092Z","iopub.status.idle":"2021-05-23T11:37:42.219576Z","shell.execute_reply.started":"2021-05-23T11:37:42.215056Z","shell.execute_reply":"2021-05-23T11:37:42.218545Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = plt.imread('../input/six-number/6.jpg')\nplt.imshow(img);","metadata":{"execution":{"iopub.status.busy":"2021-05-23T12:11:45.284070Z","iopub.execute_input":"2021-05-23T12:11:45.284444Z","iopub.status.idle":"2021-05-23T12:11:45.646363Z","shell.execute_reply.started":"2021-05-23T12:11:45.284411Z","shell.execute_reply":"2021-05-23T12:11:45.645401Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img = np.asarray(img)\nimg.shape","metadata":{"execution":{"iopub.status.busy":"2021-05-23T12:11:46.956264Z","iopub.execute_input":"2021-05-23T12:11:46.956652Z","iopub.status.idle":"2021-05-23T12:11:46.963628Z","shell.execute_reply.started":"2021-05-23T12:11:46.956619Z","shell.execute_reply":"2021-05-23T12:11:46.962378Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_test[1].shape","metadata":{"execution":{"iopub.status.busy":"2021-05-23T12:11:48.372545Z","iopub.execute_input":"2021-05-23T12:11:48.372903Z","iopub.status.idle":"2021-05-23T12:11:48.378645Z","shell.execute_reply.started":"2021-05-23T12:11:48.372873Z","shell.execute_reply":"2021-05-23T12:11:48.377942Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from skimage.transform import resize\nresized_img=resize(img,(28,28,1))","metadata":{"execution":{"iopub.status.busy":"2021-05-23T12:11:49.904549Z","iopub.execute_input":"2021-05-23T12:11:49.905127Z","iopub.status.idle":"2021-05-23T12:11:50.978419Z","shell.execute_reply.started":"2021-05-23T12:11:49.905073Z","shell.execute_reply":"2021-05-23T12:11:50.977655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(resized_img);","metadata":{"execution":{"iopub.status.busy":"2021-05-23T12:12:06.643520Z","iopub.execute_input":"2021-05-23T12:12:06.643926Z","iopub.status.idle":"2021-05-23T12:12:06.767162Z","shell.execute_reply.started":"2021-05-23T12:12:06.643889Z","shell.execute_reply":"2021-05-23T12:12:06.766177Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_man = model.predict(np.array([resized_img]))","metadata":{"execution":{"iopub.status.busy":"2021-05-23T12:12:08.872742Z","iopub.execute_input":"2021-05-23T12:12:08.873230Z","iopub.status.idle":"2021-05-23T12:12:09.579835Z","shell.execute_reply.started":"2021-05-23T12:12:08.873196Z","shell.execute_reply":"2021-05-23T12:12:09.579030Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pred_man","metadata":{"execution":{"iopub.status.busy":"2021-05-23T12:12:11.454052Z","iopub.execute_input":"2021-05-23T12:12:11.454650Z","iopub.status.idle":"2021-05-23T12:12:11.460754Z","shell.execute_reply.started":"2021-05-23T12:12:11.454598Z","shell.execute_reply":"2021-05-23T12:12:11.459786Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.argmax(pred_man)","metadata":{"execution":{"iopub.status.busy":"2021-05-23T12:12:12.484396Z","iopub.execute_input":"2021-05-23T12:12:12.484751Z","iopub.status.idle":"2021-05-23T12:12:12.490758Z","shell.execute_reply.started":"2021-05-23T12:12:12.484716Z","shell.execute_reply":"2021-05-23T12:12:12.489818Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}