fix: to_tensor applied on a jt.Var

Allow jt.transform.to_tensor applied on a jt.Var (do nothing but return the inputs).
This commit is contained in:
Zheng-Ning Liu 2021-11-09 23:00:57 +08:00 committed by GitHub
parent b3ee4a54e4
commit 4bd0c4a2f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -408,6 +408,9 @@ def to_tensor(pic):
img = Image.open(...)
img_ = transform.to_tensor(img)
"""
if isinstance(pic, jt.Var):
return pic
if isinstance(pic, tuple):
# try convert ten crop tuple
pic = ( to_tensor(pic) for p in pic )