High-resolution nuclear magnetic resonance (NMR) spectroscopy is a powerful analytical tool with wide application. However, the conventional shim technique may not guarantee the homogeneity of the magnetic field when the experimental conditions are unfavorable. In this study, we proposed a data post-processing method called Restore High-resolution Unet (RH-Unet), which uses a convolutional neural network to restore distorted NMR spectra that have been acquired in inhomogeneous magnetic fields. The method generates feature-label pairs from singlet peak regions and ideal Lorentzian line shape and trains a RH-Unet model to map low resolution spectra to high resolution spectra. The method was applied to different samples, and showed superior performance than the REFDCON method incorporated in Bruker Topspin software. The proposed method provides a simple and fast way to obtain high resolution NMR spectra in inhomogeneous fields, which can facilitate the application of NMR spectroscopy in various fields.