You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with a Dataset of images that are converted to Image type with the v2.ToImage transform, when I access them trough a direct dataset get, the type correctly remains Image, but when I load a batch trough a dataloader, the batch type is downgraded to a simple torch.Tensor.
I've tried some hacky things like trying to force the Image sublcass with a img.as_subclass(Image) in a transform called at the end of the transform pipeline, but nothing worked.
I think the problem lies with the conversion to batch with the auto-batching mechanism.
I have noticed that when working with torchvision Image type tensors, if I try to drop some channels, the new tensor is downgraded to a torch Tensor type (e.g. img[:, 0:1, ...] will become a torch.Tensor even though img is a tv_tensors.Image).
Is this an intended mechanism or a bug?
Versions
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A
OS: Ubuntu 24.04.2 LTS (x86_64)
GCC version: (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.39
Python version: 3.12.3 (main, Feb 4 2025, 14:48:35) [GCC 13.3.0] (64-bit runtime)
Python platform: Linux-6.11.0-24-generic-x86_64-with-glibc2.39
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090
Nvidia driver version: 535.183.01
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 46 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 24
On-line CPU(s) list: 0-23
Vendor ID: GenuineIntel
Model name: Intel(R) Core(TM) Ultra 9 285K
CPU family: 6
Model: 198
Thread(s) per core: 1
Core(s) per socket: 24
Socket(s): 1
Stepping: 2
CPU(s) scaling MHz: 28%
CPU max MHz: 5200.0000
CPU min MHz: 800.0000
BogoMIPS: 7372.80
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb intel_ppin ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni lam wbnoinvd dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid bus_lock_detect movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
Virtualization: VT-x
L1d cache: 768 KiB (20 instances)
L1i cache: 1.3 MiB (20 instances)
L2 cache: 40 MiB (12 instances)
L3 cache: 36 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-23
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Versions of relevant libraries:
[pip3] numpy==1.26.4
[conda] Could not collect
The text was updated successfully, but these errors were encountered:
We have documented why this happens in the link above, along with some suggested work-arounds. Please take a look, and let us know if you have any questions. I'll close this issue in the mean time
🐛 Describe the bug
I am working with a Dataset of images that are converted to
Image
type with thev2.ToImage
transform, when I access them trough a direct dataset get, the type correctly remainsImage
, but when I load a batch trough a dataloader, the batch type is downgraded to a simpletorch.Tensor
.I've tried some hacky things like trying to force the
Image
sublcass with aimg.as_subclass(Image)
in a transform called at the end of the transform pipeline, but nothing worked.I think the problem lies with the conversion to batch with the auto-batching mechanism.
I have noticed that when working with torchvision
Image
type tensors, if I try to drop some channels, the new tensor is downgraded to a torchTensor
type (e.g.img[:, 0:1, ...]
will become atorch.Tensor
even thoughimg
is atv_tensors.Image
).Is this an intended mechanism or a bug?
Versions
The text was updated successfully, but these errors were encountered: