Radio frequency interference (RFI) detection and excision is one of the key steps in the data processing pipeline of the Five-hundred-meter Aperture Spherical radio Telescope (FAST). The FAST telescope, due to its high sensitivity and large data rate, requires more accurate and efficient RFI flagging methods than its counterparts. In the last decades, approaches based upon artificial intelligence (AI), such as codes using Convolutional Neural Network (CNN), have been proposed to identify RFI more reliably and efficiently. However, RFI flagging of FAST data with such methods has often proved to be erroneous, with further manual inspections required. In addition, network construction as well as training dataset preparation for effective RFI flagging has imposed significant additional workloads. Therefore, rapid deployment and adjustment of AI approaches for different observations is impractical to implement with existing algorithms. To overcome such problems, we propose a model named RFI-Net. With the input of raw data without any processing, RFI-Net can detect RFI automatically, producing corresponding masks without any alteration of the original data. Experiments with RFI-Net using simulated astronomical data show that our model has outperformed existing methods in terms of both precision and recall. Besides, compared with other models, our method can obtain the same relative accuracy with less training data, thus saving effort and time required to prepare the training set. Further, the training process of RFI-Net can be accelerated, with overfittings being minimised, compared with other CNN codes. The performance of RFI-Net has also been evaluated with observing data obtained by FAST and Bleien Observatory. Our results demonstrate the ability of RFI-Net to accurately identify RFI with fine-grained, high-precision masks that required no further modification.