You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
JAVerma
changed the title
Error in dataset.py add additional check in padding function in ./dataset/dataset.py
Error in dataset.py , to fix add additional check in padding function in ./dataset/dataset.py
May 9, 2023
when i was training i was getting
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)
The text was updated successfully, but these errors were encountered: