Error: (-215:Assertion failed) !dsize.empty() in function 'resize'

aand ? thresholded.shape is what ?

however, before we try to fix your current errors – what exactly did you train your network on ? color images ? then you must use the same for prediction, so most probably you should remove all that preprocessing