Accurately measuring magnetic fields is essential for magnetic-field sensitive experiments in areas like atomic, molecular, and optical physics, condensed matter experiments, and other areas. However, since many experiments are often conducted in an isolated environment that is inaccessible to experimentalists, it can be challenging to accurately determine the magnetic field at the target location. Here, we propose an efficient method for detecting magnetic fields with the assistance of an artificial neural network (NN). Instead of measuring the magnetic field directly at the desired location, we detect fields at several surrounding positions, and a trained NN can accurately predict the magnetic field at the target location. After training, we achieve a below 0.3% relative prediction error of magnetic field magnitude at the center of vacuum chamber, and successfully apply this method to our erbium quantum gas apparatus for accurate calibration of magnetic field and long-term monitor of environmental stray magnetic field. The demonstrated approach significantly simplifies the process of determining magnetic fields in isolated environments and can be applied to various research fields across a wide range of magnetic field magnitudes.