# -*- coding: utf-8 -*- """CS297 : ASL.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1jytY45z-cSW1MC_V_2up9lyHk9JFnlhh """ from google.colab import drive drive.mount('/content/drive',force_remount=True) cd /content/drive/My Drive/MS_CS/CS297 import pandas as pd import numpy as np train = pd.read_csv("/content/drive/My Drive/MS_CS/CS297/Dataset/sign_mnist_train.csv") test = pd.read_csv("/content/drive/My Drive/MS_CS/CS297/Dataset/sign_mnist_test.csv") #understand input data print('training images =',train.shape) print('testing images =',test.shape) import numpy as np import matplotlib.pyplot as plt import pandas as pd print(train) Y_train = train[['label']] X_train = train.drop(train.columns[[0]], axis=1) # X_test = test Y_test = test[['label']] X_test = test.drop(test.columns[[0]], axis=1) #Visualizing the data sampleimage = X_train.iloc[1, :] #take any row from 27455 rows eg: 2 sampleimage = sampleimage.values.reshape([28,28]) plt.imshow(sampleimage, cmap='gray') print(train[['label']]) #conver to numpy array X_train = np.array(X_train) X_test = np.array(X_test) print(X_train.shape, X_test.shape) print(Y_train.shape, Y_test.shape) print(Y_train) #Reshape the training and test set X_train = X_train.reshape(X_train.shape[0], 28, 28, 1) X_test = X_test.reshape(X_test.shape[0], 28, 28, 1) print(X_train.shape, X_test.shape) print(Y_train.shape, Y_test.shape) #Padding the images by 2 pixels since in the paper input images were 32x32 X_train = np.pad(X_train, ((0,0),(2,2),(2,2),(0,0)), 'constant') X_test = np.pad(X_test, ((0,0),(2,2),(2,2),(0,0)), 'constant') #Standardization mean_px = X_train.mean().astype(np.float32) std_px = X_train.std().astype(np.float32) X_train = (X_train - mean_px)/(std_px) #One-hot encoding the labels from keras.utils.np_utils import to_categorical Y_train = to_categorical(Y_train) import keras from keras.models import Sequential from keras.layers import Conv2D from keras.layers import MaxPooling2D from keras.layers import Flatten from keras.layers import Dense """Keras implementataion of LeNet-5 Model""" model = Sequential() #Conv Layer 1 model.add(Conv2D(filters=6,kernel_size = 5,strides= 1,activation= 'relu',input_shape =(32,32,1))) #Pooling layer 1 model.add(MaxPooling2D(pool_size=2, strides=2)) #Conv Layer 2 model.add(Conv2D(filters = 16,kernel_size= 5, strides=1,activation ='relu', input_shape =(14,14,6))) #Pooling Layer 2 model.add(MaxPooling2D(pool_size=2, strides=2)) #Flatten Layer model.add(Flatten()) #Fully-connected Layer1 model.add(Dense(units=120, activation ='relu')) #Fully-connected Layer2 model.add(Dense(units=25, activation= 'relu')) #Final Output Layer : softmax classifier model.add(Dense(units = 25, activation = 'softmax')) model.compile(optimizer = 'adam', loss = 'categorical_crossentropy', metrics = ['accuracy']) #print model summary print(model.summary()) """Training The Model""" #train the data on lenet5 arch model.fit(X_train ,Y_train, steps_per_epoch = 10, epochs = 20) """Testing The model on Test Data Set""" # get predictions on test data y_pred = model.predict(X_test) print(y_pred) labels = np.argmax(y_pred, axis = 1) print(labels.size) y_pred = model.predict(X_test) #Converting one hot vectors to labels labels = np.argmax(y_pred, axis = 1) index = np.arange(0, 7172) labels = labels.reshape([len(labels),1]) index = index.reshape([len(index), 1]) final = np.concatenate([index, labels], axis = 1) #Prediction csv file np.savetxt("predictionsTestDataset.csv", final, delimiter = " ", fmt = '%s') print(final) """Test on random images""" img ="203 205 207 206 207 209 210 209 210 209 208 207 207 209 208 210 210 207 209 209 208 209 210 209 207 208 209 207 206 208 209 208 208 210 211 210 211 209 209 210 211 211 209 208 211 215 210 212 212 211 211 210 210 211 210 210 209 209 210 211 210 210 212 212 211 212 210 210 212 211 223 208 162 176 219 204 206 217 216 214 212 209 211 212 209 210 211 213 215 213 211 213 213 211 216 216 179 167 228 202 161 129 132 155 141 187 210 159 197 217 211 211 210 211 211 213 214 213 213 214 215 216 245 228 181 138 184 210 175 160 76 133 143 118 180 126 170 225 211 214 210 212 213 213 213 215 213 221 198 181 245 225 192 156 176 234 181 168 95 158 159 121 145 134 161 228 214 216 211 213 214 215 215 215 218 252 199 142 192 244 200 166 160 249 199 175 102 176 164 113 111 137 131 232 213 217 213 214 214 215 217 211 235 246 207 174 164 250 211 166 144 248 204 171 96 179 161 98 94 152 85 209 221 217 214 216 216 216 214 233 229 227 222 190 140 226 220 160 123 239 206 155 77 138 144 88 82 161 76 141 233 216 215 216 217 216 217 237 194 217 235 197 131 193 228 158 100 198 194 137 69 105 127 78 84 166 89 111 231 218 217 217 219 214 230 230 180 192 229 195 129 156 217 151 87 153 177 128 78 88 114 64 102 178 106 115 233 220 217 218 218 216 230 223 188 176 204 173 118 121 191 141 81 110 168 123 74 88 117 74 157 195 120 119 234 222 213 216 215 221 232 209 174 140 183 167 113 96 178 139 71 82 166 122 64 111 127 97 196 189 122 128 235 221 213 215 215 215 246 229 187 129 145 170 101 83 169 144 70 75 173 120 130 197 163 118 184 196 122 138 234 220 215 217 216 217 244 231 192 146 100 141 131 79 171 165 82 85 170 173 196 194 173 137 132 180 112 145 236 221 217 218 217 221 248 235 206 169 123 109 140 103 164 178 148 189 206 203 191 177 154 137 114 117 91 138 238 220 218 219 219 221 249 243 214 182 164 151 142 164 185 198 218 220 218 207 189 170 143 121 113 92 73 131 239 220 217 218 217 222 244 243 223 200 185 173 160 160 187 205 218 217 218 209 183 164 142 114 99 93 66 159 238 222 216 216 217 221 238 238 231 215 204 182 170 165 178 201 215 216 211 202 177 157 136 110 96 76 113 222 230 227 222 223 224 216 233 239 240 229 210 187 171 168 180 207 218 218 203 194 174 153 129 107 80 97 213 227 225 226 175 180 188 178 214 240 245 233 210 191 174 167 179 211 220 211 196 186 168 143 118 96 78 196 239 230 234 233 94 96 103 85 151 244 234 226 211 195 181 165 178 207 207 192 178 168 153 129 107 86 104 177 178 182 178 177 103 103 104 91 114 239 220 212 211 202 188 164 173 203 198 178 156 140 127 115 95 92 99 95 90 86 113 156 101 103 105 99 106 230 209 204 214 204 185 164 167 201 194 168 131 109 103 93 93 104 98 97 131 187 234 233 100 101 100 102 104 222 207 205 215 199 183 172 164 193 187 153 107 91 86 93 102 108 141 195 241 242 226 207 100 101 100 104 98 222 224 209 212 193 178 175 159 171 173 135 92 85 85 92 120 208 252 255 246 237 229 204 101 100 100 102 93 220 233 219 210 191 179 182 155 159 164 123 85 80 84 151 238 255 255 250 237 245 250 232 103 101 102 103 95 208 231 227 209 190 179 182 152 150 159 119 83 63 154 248 247 248 253 236 230 240 253 255" img="128 131 133 135 137 139 140 142 145 146 146 145 144 149 147 147 148 148 146 147 147 147 149 148 145 145 144 142 129 132 134 137 139 140 143 145 146 147 145 153 161 130 148 151 150 150 149 149 149 149 149 149 148 146 147 146 131 134 136 139 141 143 145 146 147 150 147 165 189 123 123 157 152 152 152 152 152 152 151 150 151 151 149 147 133 136 138 140 143 145 147 148 150 152 153 150 190 154 98 151 156 153 154 153 153 154 152 155 146 141 152 148 133 137 139 142 144 146 148 150 152 153 155 150 172 181 125 130 159 155 156 155 155 156 153 174 135 101 156 151 134 139 141 144 145 147 150 152 154 153 154 153 159 197 162 116 153 159 157 158 158 155 160 182 123 105 159 151 136 140 143 145 146 149 151 154 155 155 156 158 154 192 179 118 134 163 158 158 159 154 174 176 108 126 160 152 139 141 144 146 148 151 152 154 155 157 157 159 153 181 189 132 118 163 159 159 160 161 188 162 105 148 160 156 140 143 145 147 151 153 153 155 157 158 159 160 157 171 186 153 109 160 162 162 158 172 180 139 103 161 158 157 141 144 147 150 152 154 155 157 158 160 161 158 170 198 178 159 94 123 169 159 163 185 170 109 122 167 158 158 142 146 148 151 153 155 157 158 159 161 160 166 175 194 181 155 120 92 151 167 173 187 160 99 154 165 161 159 144 146 148 152 155 157 158 159 160 162 164 201 171 163 198 172 164 152 117 144 166 171 127 111 170 162 163 161 145 148 151 153 156 158 159 160 163 162 173 184 184 167 151 159 190 174 114 89 130 132 94 140 170 163 164 163 146 149 151 153 157 159 160 162 164 161 176 176 150 117 71 80 165 174 128 85 97 101 91 164 166 165 165 164 147 150 152 155 158 159 161 164 166 162 180 171 115 114 97 78 117 191 153 102 79 80 104 173 166 166 165 165 147 151 153 156 158 160 163 165 166 164 184 180 165 144 106 108 103 184 177 119 79 68 121 177 167 168 167 167 149 152 155 158 159 162 164 166 167 164 195 197 156 127 109 126 122 186 194 142 94 64 126 178 168 170 170 169 151 153 156 158 160 163 164 166 169 167 198 180 136 123 128 142 152 203 193 155 111 70 121 180 168 170 169 169 150 153 156 159 161 164 165 167 169 169 197 184 156 149 148 150 178 206 186 153 115 71 121 180 169 170 170 169 149 152 156 158 161 164 164 166 169 166 198 195 166 152 157 165 191 206 184 146 122 74 118 181 169 171 170 170 151 154 156 159 162 164 165 167 170 166 194 202 177 154 163 174 201 205 188 148 121 77 122 182 170 171 171 170 152 156 159 161 163 164 166 168 171 167 191 206 180 164 163 185 206 196 181 145 118 75 127 182 172 172 172 171 153 156 159 160 163 165 167 169 173 171 186 206 184 182 173 188 206 194 174 146 112 73 122 185 173 175 174 174 153 157 159 163 164 166 170 171 173 173 179 205 193 192 186 182 201 182 166 143 106 70 118 186 174 176 175 175 155 157 160 163 164 168 171 172 174 174 173 195 200 195 188 177 186 167 153 139 101 66 124 187 176 175 179 177 149 153 157 160 164 167 170 172 174 176 173 188 204 195 177 159 169 160 144 144 96 59 151 192 182 185 167 114 102 103 106 110 112 113 117 118 118 118 120 138 202 186 160 136 145 160 141 140 87 59 135 145 144 148 95 71 78 79 79 79 77 79 82 81 78 83 70 57 184 169 142 127 140 161 131 130 73 45 61 76 84 85 65 66" img ="126 128 131 132 133 134 135 135 136 138 137 137 138 138 139 137 142 140 138 139 137 137 136 135 134 133 134 132 129 132 134 135 135 137 139 139 139 140 141 141 142 143 142 142 116 138 141 140 141 140 139 138 137 136 136 134 133 135 138 139 139 141 142 143 142 143 145 145 143 145 145 158 94 118 151 143 144 144 142 141 141 140 139 138 137 139 142 142 142 144 146 146 146 147 147 147 148 117 128 168 101 98 157 146 147 146 146 145 144 143 142 141 140 142 145 146 147 148 149 149 149 151 151 149 161 114 99 174 99 84 162 149 151 149 148 147 146 146 145 144 143 145 149 150 150 151 153 153 154 153 154 152 167 126 88 169 99 87 164 152 153 152 151 150 149 148 148 147 145 147 151 152 153 155 155 155 151 154 158 155 170 130 79 166 111 93 166 156 157 156 155 153 152 152 152 150 149 150 153 155 155 158 157 163 129 120 166 156 171 140 82 162 102 97 168 158 160 158 162 160 154 154 154 152 151 152 156 158 159 159 158 164 139 91 165 159 174 144 71 156 96 100 171 161 161 158 128 145 162 156 155 155 152 155 159 160 161 161 160 168 158 76 159 164 172 142 63 155 117 100 174 159 164 164 126 103 162 161 158 157 153 157 160 162 162 162 164 167 158 78 158 167 167 156 73 133 129 102 172 157 148 130 156 132 129 163 161 159 157 159 162 164 164 165 166 167 173 89 139 172 162 163 79 98 132 111 170 160 142 54 125 150 102 150 167 162 159 161 166 165 167 167 167 168 178 118 112 175 164 167 82 91 129 110 160 156 130 96 157 130 106 169 165 164 159 162 166 167 168 168 170 169 164 168 132 141 162 153 103 113 117 96 133 143 107 147 172 99 139 174 165 166 161 164 167 170 171 171 170 173 160 173 162 129 132 132 109 109 108 99 135 142 111 163 154 77 156 172 167 167 165 167 168 171 172 173 173 174 169 170 182 150 125 124 100 106 103 102 130 138 124 178 130 64 168 172 170 169 165 168 170 171 172 174 175 174 175 172 195 170 114 110 94 89 98 105 127 134 124 182 126 80 180 171 171 171 166 169 171 172 173 174 175 176 177 174 197 179 119 86 87 81 94 118 136 123 116 177 127 94 183 172 173 173 169 172 172 174 175 174 177 178 178 175 192 176 126 87 86 82 109 130 147 159 128 164 128 100 184 174 173 173 169 172 173 173 176 178 179 178 181 175 189 171 126 89 80 90 121 137 164 175 141 140 108 95 184 176 175 173 171 173 174 175 177 179 179 179 181 174 189 171 134 91 80 98 134 159 164 167 153 114 73 82 185 176 177 177 172 173 174 177 178 179 180 180 183 174 186 172 138 93 82 97 143 172 169 160 132 89 44 108 189 176 178 178 171 173 177 178 179 180 181 182 185 178 179 170 137 95 88 90 152 180 167 141 112 65 64 176 183 179 179 178 173 174 178 179 179 180 182 183 186 175 165 168 137 100 96 88 149 168 147 122 92 50 144 193 181 181 180 179 173 174 177 179 180 180 183 182 187 177 158 161 130 111 101 91 136 150 135 112 62 87 192 183 185 183 181 180 173 174 177 178 179 179 181 182 184 179 156 151 124 116 96 88 128 138 126 81 49 164 190 184 185 184 182 181 172 174 177 178 178 178 180 182 184 177 160 154 128 114 97 78 114 112 89 48 133 194 182 185 184 184 182 181 172 174 177 178 178 179 181 183 187 175 165 154 118 107 100 75 96 83 47 104 194 183 186 184 184 184 182 180" img ="171 172 172 173 173 173 173 173 172 172 172 171 170 170 169 168 168 166 165 165 164 164 152 86 72 61 65 85 174 174 174 175 175 175 175 175 175 174 174 173 172 172 172 171 170 167 166 166 166 165 168 104 64 49 59 73 175 176 176 178 179 178 176 177 177 177 176 175 174 174 173 172 172 170 169 169 168 168 171 129 49 38 56 63 178 179 181 180 181 181 180 179 179 179 178 178 178 177 175 174 174 173 172 171 170 169 169 159 59 32 44 57 179 180 182 181 182 181 181 181 181 181 180 180 180 180 177 176 176 175 173 172 172 170 170 171 122 71 53 71 180 181 182 183 184 182 183 184 184 183 181 181 180 169 168 172 171 164 158 161 153 169 168 166 128 132 142 130 182 184 185 186 187 186 186 185 184 184 183 185 183 163 152 171 176 163 151 151 140 175 164 151 94 155 166 158 185 187 188 188 187 187 188 188 189 195 200 198 187 166 159 165 152 151 136 134 129 127 128 156 114 163 127 148 186 188 188 190 189 186 184 193 203 206 205 195 185 176 175 165 129 128 152 141 135 125 122 124 112 138 114 172 187 190 191 191 206 197 187 189 196 195 191 188 186 185 179 161 142 134 150 147 140 139 124 105 106 138 122 176 189 191 190 204 220 206 193 186 190 193 191 190 188 183 179 156 143 135 126 118 115 114 103 96 89 102 126 164 190 191 192 220 221 206 178 169 179 190 190 186 178 165 153 133 120 112 108 112 117 125 123 130 140 150 169 175 193 193 202 226 217 197 166 167 177 169 163 153 141 132 120 106 105 163 184 181 183 184 182 183 181 180 168 116 195 193 218 224 213 193 182 176 163 154 158 162 156 150 145 148 129 99 166 191 188 185 184 182 180 179 178 121 193 201 229 222 218 215 211 185 162 166 167 166 156 146 142 139 120 67 58 174 190 186 184 184 181 180 179 164 190 217 228 225 223 223 218 180 148 158 156 150 143 139 132 122 105 72 41 150 193 188 186 184 183 180 179 179 205 229 228 225 222 218 206 172 152 139 117 104 113 127 137 143 143 85 69 175 191 188 188 186 185 182 181 178 226 230 229 226 220 211 197 178 160 143 123 124 154 170 158 147 156 108 169 193 190 189 189 187 185 184 181 179 228 230 229 224 214 205 188 167 165 165 145 152 164 155 145 135 129 96 186 195 192 191 190 188 186 184 183 181 229 229 226 221 208 187 165 172 187 176 154 152 148 138 132 122 101 91 192 196 194 192 190 190 188 186 184 182 230 227 223 215 196 183 185 199 197 180 157 130 117 105 92 80 83 153 199 196 196 194 192 190 189 188 185 182 227 221 214 204 197 197 199 195 186 163 132 105 101 114 90 131 178 199 198 197 196 195 193 190 188 188 185 184 219 212 206 203 203 202 188 178 173 152 124 107 173 203 196 203 203 200 200 197 196 196 194 193 189 188 187 186 207 205 207 200 196 194 180 175 162 128 100 175 209 205 205 203 201 201 200 199 197 196 195 194 192 190 188 185 199 196 200 194 185 181 174 158 126 95 164 210 206 205 203 202 202 202 202 199 199 197 196 194 192 190 189 180 198 192 187 177 167 164 151 124 92 152 210 206 204 204 203 202 201 201 199 197 197 196 196 194 192 193 188 171 193 184 172 155 147 137 112 92 153 209 208 207 205 205 203 202 201 201 199 198 197 196 195 192 192 170 165 177 173 160 143 127 115 100 85 155 212 207 208 207 207 205 203 202 201 201 199 199 198 196 195 194 183 85 65 124" """Plot the pixel csv to image""" from PIL import Image input="162 165 168 171 173 174 177 179 180 180 181 181 182 183 183 183 183 183 184 184 184 184 184 183 182 181 181 180 164 167 170 173 175 177 179 181 182 182 183 183 184 184 185 185 186 186 186 186 186 186 186 186 184 183 183 182 166 169 172 175 178 180 182 183 184 185 185 186 187 187 187 188 187 187 187 187 187 188 188 188 187 186 185 185 168 171 174 178 181 183 184 185 187 187 187 188 188 189 190 190 190 190 190 190 190 190 191 190 189 188 188 187 168 170 176 180 183 185 186 188 188 189 190 191 191 192 192 192 192 193 193 193 193 192 193 192 191 190 189 188 153 150 175 183 185 187 188 190 190 191 192 193 193 193 194 194 195 195 195 195 195 195 195 194 194 192 192 191 137 122 169 185 187 189 191 193 193 194 194 194 194 196 196 196 197 198 197 197 197 197 197 197 194 190 190 193 130 110 164 186 189 191 193 194 193 194 195 187 182 191 197 199 199 199 199 199 199 199 197 189 175 155 164 191 121 101 163 188 190 188 190 190 176 172 186 172 150 157 190 200 200 200 201 201 201 200 191 168 139 119 152 192 115 99 162 190 186 167 167 185 163 145 166 173 152 136 169 199 201 201 202 202 202 199 187 152 116 135 183 199 125 104 157 192 195 172 159 178 172 154 156 176 169 142 147 194 203 203 203 203 202 196 176 132 122 178 200 201 141 120 156 192 202 195 172 165 180 171 150 163 175 145 130 184 204 205 205 203 199 188 154 113 146 198 203 203 165 155 167 188 193 198 184 150 160 179 154 139 159 132 110 173 204 203 198 192 187 164 122 123 182 205 205 204 183 181 179 185 180 178 180 135 123 169 155 113 112 103 96 156 187 186 177 166 157 126 116 170 205 208 206 206 185 191 187 185 180 169 160 124 99 131 129 87 68 90 119 159 180 179 162 140 120 108 156 203 209 209 208 207 188 194 188 182 177 163 150 128 102 95 97 76 77 124 169 187 187 173 146 117 102 134 196 211 210 210 209 209 190 194 186 168 163 157 150 138 120 107 106 114 144 175 192 192 179 158 126 98 109 178 211 213 212 211 211 210 191 194 193 176 157 153 161 156 149 138 140 168 191 197 193 183 165 139 106 96 150 205 214 214 213 212 212 211 191 194 201 196 173 154 155 165 176 180 185 201 204 198 187 169 146 115 95 134 197 214 215 215 214 213 213 212 191 194 199 203 189 166 153 161 178 197 206 208 205 195 175 150 122 96 114 184 214 216 215 215 215 214 213 213 192 195 197 204 203 183 164 164 180 203 212 212 206 186 156 127 100 96 158 209 215 216 215 215 214 214 213 212 192 195 198 206 213 203 181 175 185 207 217 211 195 166 133 105 88 123 196 216 216 216 215 215 214 214 213 213 193 195 198 200 208 211 195 184 188 204 211 201 176 142 111 87 93 167 213 218 218 218 217 217 215 213 207 197 193 195 197 194 193 201 195 187 186 188 190 182 158 123 92 78 121 199 217 218 219 218 217 217 215 207 196 164 176 179 183 183 177 183 188 183 176 167 165 165 145 111 83 81 153 209 216 216 217 217 217 215 204 197 199 175 123 126 128 131 134 160 180 173 161 151 152 156 137 110 86 84 139 172 177 179 182 187 191 198 199 187 177 147 103 104 105 105 107 133 165 154 146 147 156 160 138 115 96 81 100 115 116 118 119 123 138 177 201 184 161 138 104 106 109 109 108 119 151 146 149 157 164 164 139 116 102 84 96 110 112 112 110 115 139 162 194 187 137 146" arr = input.split("\t") inputimgarray = np.array(arr[:]) inputimg = np.array(inputimgarray, dtype='uint8') inputimg = inputimg.reshape((28, 28)) outputimage = Image.fromarray(inputimg) plt.imshow(outputimage,cmap='gray') """Predict the ASL Alphabet for the given input image""" # pixel reshape pred_img = inputimg.reshape(1,28, 28, 1) #pad it to make 32 32 pred_img = np.pad(pred_img, ((0,0),(2,2),(2,2),(0,0)), 'constant') print(pred_img.shape) imp_pred = model.predict(pred_img) # print(imp_pred) letter = np.argmax(imp_pred, axis = 1) letter = letter.reshape([len(imp_pred),1]) print('Predicted ASL Alphabet:',chr(65+letter)) ##### END #### """other """ # Commented out IPython magic to ensure Python compatibility. # %ls from __future__ import with_statement from PIL import Image img_file = Image.open('asl_f.png') #relative path to file pix = img_file.load() width, height = img_file.size format = img_file.format mode = img_file.mode # Make image Greyscale img_grey = img_file.convert('L') img_grey.save('result.png') img_grey.show() # Save Greyscale values value = np.asarray(img_grey.getdata(), dtype=np.int).reshape((img_grey.size[1], img_grey.size[0])) value = value.flatten() print(value) print(height, width) # pixel reshape value = value.reshape(1,32, 32, 1) print(value.shape) imp_pred = model.predict(value) print(imp_pred) letter = np.argmax(imp_pred, axis = 1) print(letter) letter = letter.reshape([len(imp_pred),1]) print(letter) #import cv2 # cam = cv2.VideoCapture(0) #0=front-cam, 1=back-cam # cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1300) # cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 1500) while True: # ## read frames # ret, img = cam.read() # ## predict yolo # img, preds = model.predict(input_image=img, # custom_objects=None, input_type="array", # output_type="array", # minimum_percentage_probability=70, # display_percentage_probability=False, # display_object_name=True) # ## display predictions # cv2.imshow("", img) # ## press q or Esc to quit # if (cv2.waitKey(1) & 0xFF == ord("q")) or (cv2.waitKey(1)==27): # break # ## close camera # cam.release() # cv2.destroyAllWindows() # plt.scatter(X_train, Y_train, color = "red") # plt.plot(Y_test, y_pred, color = "red") # plt.title(" testing v/s predicted") # plt.xlabel("class") # plt.ylabel("y") # plt.show() # accuracy = model.evaluate(x=X_test, y=Y_test, batch_size=32)