'Is there a way we can classify between chest xray and not chest xray using keras?

I'm new to deep learning and recently have been trying out some codes in Keras to develop a pneumonia classification program which uses a dataset that contains chest x-ray images. But before even using that program I want to add another layer of classification that will detect if the uploaded image is a chest Xray or not. If the uploaded image is a chest x-ray then only the pneumonia classification code will trigger or else it will show an error. As of now the code I am using for pneumonia classification accepts any kind of images, be it chest x-ray or an image of a dog or a cat and as such gives a prediction no matter what. So, I wanted to know if there is a way we can classify the uploaded image is a chest x-ray or an image of something else.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source