This is how classification works. The classifier learns to approximate the boundaries between the classes it was trained on. However, it doesn’t know where the boundary is among the set of trained classes and all the other (unknown, unseen) classes which might exist in the world.
Determining whether an item is of the known class versus “something else” is a separate problem in machine learning. You can Google “one-class classification” to learn more about that problem in general.
As a practical matter, I would suggest thinking about the real-world use cases of your application. Is anyone really going to upload a photo of a building to a site that detects dog breeds? Probably not, at least not with serious intent. But if there are specific types of things you think users might actually be confused about, you can price that into your design and add an “other” category with examples of those things
Finally, about your result from learn.predict(): this is normal. For a standard classification task, the neural network has a final softmax layer. Softmax will output a set of numbers where: a) the numbers add up to 1.0, and b) the numbers tend to be close to 0 or close to 1. Even if you input a photo of a blank piece of paper, you can be fairly sure the neural net will predict one of the dog breeds as a clear winner. Again, that’s because it’s designed to discriminate between examples of the types of things it was trained on. So when you give it something really different from the training data, you’re going to get a meaningless result.