Uncertainty estimation is a critical component of building safe and reliable machine learning models. Accurate estimation of uncertainties is essential for identifying and mitigating potential risks and ensuring that machine learning systems operate reliably in real-world scenarios. Various approaches, such as ensemble and Bayesian neural networks have been developed by sampling probability predictions from submodels, which is computatinally expensive. Currently, these methods are unable to clearly define the boundary between in distribution (ID) and out-of-distribution (OOD) data. To fill up this research gap, this paper presents a normalizing flow based framework to directly predict parameters of prior distributions over the probability with a neural network, which is capable of effectively distinguishing ID and OOD data for regression problems. The posterior distributions learned by the proposed model accurately model uncertainties for OOD data from ID data without requiring OOD data at training time. This approach has shown promising results in a number of applications, including image depth estimation and image adversarial attacks.