Skip to content

Loading the weights #3

@aibak365

Description

@aibak365

I am trying to use the evaluation.py code to make an experiment on my research using an ubuntu machine

but keep facing this error
Traceback (most recent call last):
File "/home/aljadaaa/Documents/Aibak_research_stuff/NSFW (2)/NSFW/Testing/defense/GuardT2I/evaluation.py", line 134, in
clip_model = torch.load("/home/aljadaaa/Documents/Aibak_research_stuff/NSFW (2)/NSFW/Testing/defense/GuardT2I/GuardT2I/clip_model.pt",)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aljadaaa/Documents/Aibak_research_stuff/NSFW (2)/NSFW/.venv/lib/python3.12/site-packages/torch/serialization.py", line 1494, in load
raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
Please file an issue with the following so that we can make weights_only=True compatible with your use case: WeightsUnpickler error: Unsupported operand 118

Check the documentation of torch.load to learn more about types accepted by default with weights_only https://pytorch.org/docs/stable/generated/torch.load.html.

please note that I have tried the weights_only = True and was the same error
and i have tried with false and got the following

Traceback (most recent call last):
File "/home/aljadaaa/Documents/Aibak_research_stuff/NSFW (2)/NSFW/Testing/defense/GuardT2I/evaluation.py", line 134, in
clip_model = torch.load("/home/aljadaaa/Documents/Aibak_research_stuff/NSFW (2)/NSFW/Testing/defense/GuardT2I/GuardT2I/clip_model.pt",weights_only = False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/aljadaaa/Documents/Aibak_research_stuff/NSFW (2)/NSFW/.venv/lib/python3.12/site-packages/torch/serialization.py", line 1495, in load
return _legacy_load(
^^^^^^^^^^^^^
File "/home/aljadaaa/Documents/Aibak_research_stuff/NSFW (2)/NSFW/.venv/lib/python3.12/site-packages/torch/serialization.py", line 1744, in _legacy_load
magic_number = pickle_module.load(f, **pickle_load_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_pickle.UnpicklingError: invalid load key, 'v'.

it looks some issues related to the serilization process?
could you please help me to figure it out?

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