Make sure the input_img's resolution is not zero, i.e, (0,0,number_of_channels) which means it is not finding any image.
So add the following checking before performing operations on it:
if input_img.shape[0]!=0 and input_img.shape[1]!=0:
#operations on input_img