I dont see anything obviously wrong with what you are doing. Can you try re-save test_image to disk along-side test_img, and see if it has something to do with loading paths?
Also the function body of m i.e. of m(test_scoremap) is not in your snippet, check if there’s any bugs in that.