snap-research / NeROIC

Other
960 stars 124 forks source link

Error in dataset.py , to fix add additional check in padding function in ./dataset/dataset.py #30

Open JAVerma opened 1 year ago

JAVerma commented 1 year ago

when i was training i was getting Screenshot_20230509_183842

this is because image dimension is greater than sh, thus need to add additional check in padding function def padding(img, sh, pad_value=0): if sh[0]<img.shape[0]: new_w,new_h=int(img.shape[1]/img.shape[0])sh[0],sh[0] print(new_w,new_h,type(img)) img=cv2.resize(img.astype(np.uint8),(new_w,new_h)) elif sh[1]<img.shape[1]: new_h,new_w=int(img.shape[0]/img.shape[1])sh[1],sh[1] img=cv2.resize(img.astype(np.uint8),(new_w,new_h)) else: img=img if img.ndim == 2: return np.pad(img, [(0,sh[0]-img.shape[0]), (0, sh[1]-img.shape[1])], 'constant', constant_values=pad_value) else: return np.pad(img, [(0,sh[0]-img.shape[0]), (0, sh[1]-img.shape[1]), (0,0)], 'constant', constant_values=pad_value)