How to save and test CNN model on test set after training
I don't know exactly where you have the problem but according to comments, take a look at the following line.

_, c = sess.run([optimizer, cost], feed_dict={x_img: X, y_label: Y})


feed_dict is used for passing data to your network. As you can see, X is the training data. You can replace it with the test data. You should also change the y_labels to the labels of the test data.