Getting error by performing piltotensor operation?

Hello everyone,
I am working on a detection project where I am getting issues while I am converting pixel data to pil the code is given below but in parallel when I ran it on a fresh open environment it run and it converts to a pil image.
Why is it doing this?
The error along code is:

     64         img = to_rgb(img)
---> 66         img = Image(pil2tensor(img, dtype=np.float32).div_(255))
     67         print('-----Model Detecting Abnormal Regions-----')
     68         print('-----Results Generated-----')

TypeError: 'module' object is not callable

why it’s showing a module error while I was doing done it before without any error but when I run it again it getting this issue why?

Here is the same code for a simple image where it work fine:

img_path = '/home/test/test3.dicom'
xray = read_xray(img_path)
img = resize(xray)
img = to_rgb(img)
img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) 
img = Image(pil2tensor(img, dtype=np.float32).div_(255))
print(type(img))
#output
<class 'fastai.vision.image.Image'>

Please help to sort this issue
Thanks