8000 V2 transforms tests failing due to pickle FutureWarning (coming from torch.load) · Issue #8517 · pytorch/vision · GitHub
[go: up one dir, main page]

Skip to content
V2 transforms tests failing due to pickle FutureWarning (coming from torch.load) #8517
@NicolasHug

Description

@NicolasHug

Our v2 transforms tests started failing for RandomResizedCrop and LinearTransform with:

__________________________________________ TestResizedCrop.test_transform[make_video-ratio-value2] ___________________________________________
test/test_transforms_v2.py:3659: in test_transform
    check_transform(
test/test_transforms_v2.py:397: in check_transform
    pickle.loads(pickle.dumps(transform))
../../.miniconda3/envs/pt/lib/python3.11/site-packages/torch/storage.py:505: in _load_from_bytes
    return torch.load(io.BytesIO(b))
../../.miniconda3/envs/pt/lib/python3.11/site-packages/torch/serialization.py:1160: in load
    warnings.warn(
E   FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.

The offending line is

pickle.loads(pickle.dumps(transform))

The warning (converted to an error) is only emitted with RandomResizedCrop and LinearTransform and not on the other transforms. This is because these 2 transforms have an attribute that is a tensor.

Opened pytorch/pytorch#130242 on core

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0