Solved by eqy in post #2 
              
              
                This looks like an issue that has recently surfaced; you might want to see if downgrading to PIL 8.2 works. 
Issues: 
transform toTensor fails with PIL image · Issue #4146 · pytorch/vision (github.com) 
Pillow 8.3 and NumPy · Issue #5571 · python-pillow/Pillow (github.com)