We demonstrate that an image recognition algorithm based on a convolutional neural network provides a powerful procedure to differentiate between ergodic, non-ergodic extended (fractal) and localized phases in various systems: single-particle models, including random-matrix and random-graph models, and many-body quantum systems. The network can be successfully trained on a small data set of only 500 wave functions (images) per class for a single model. The trained network can then be used to classify phases in the other models and is thus very efficient. We discuss the strengths and limitations of the approach.