Skip to content

Model training error #52

@XiangmengCai

Description

@XiangmengCai

Code:

!export PYTHONPATH='C.Origami/src' && \
 python C.Origami/src/corigami/inference/prediction.py \
    --chr "chr10" \
    --celltype "gm12878" \
    --start 78000000 \
    --model "./corigami_data/model_weights/corigami_base.ckpt" \
    --seq "./corigami_data/data/hg38/dna_sequence" \
    --ctcf "./corigami_data/data/hg38/gm12878/genomic_features/ctcf_log2fc.bw" \
    --atac "./corigami_data/data/hg38/gm12878/genomic_features/atac.bw"

Error message:

Reading sequence: ./corigami_data/data/hg38/dna_sequence/chr10.fa.gz
Feature path: ./corigami_data/data/hg38/gm12878/genomic_features/ctcf_log2fc.bw 
 Normalization status: None
Feature path: ./corigami_data/data/hg38/gm12878/genomic_features/atac.bw 
 Normalization status: log
Initializing ConvModel
Initializing ConvTransModel
Loading weights
Traceback (most recent call last):
  File "/content/C.Origami/src/corigami/inference/prediction.py", line 42, in <module>
    main()
  File "/content/C.Origami/src/corigami/inference/prediction.py", line 27, in main
    single_prediction(args.output_path, args.celltype, 
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/content/C.Origami/src/corigami/inference/prediction.py", line 35, in single_prediction
    pred = infer.prediction(seq_region, ctcf_region, atac_region, 
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/content/C.Origami/src/corigami/inference/utils/inference_utils.py", line 53, in prediction
    model = load_default(model_path)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/content/C.Origami/src/corigami/inference/utils/model_utils.py", line 12, in load_default
    load_checkpoint(model, model_path)
  File "/content/C.Origami/src/corigami/inference/utils/model_utils.py", line 25, in load_checkpoint
    checkpoint = torch.load(model_path, map_location=device)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/torch/serialization.py", line 1529, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, do those steps only if you trust the source of the checkpoint. 
	(1) 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.
	(2) Alternatively, to load with `weights_only=True` please check the recommended steps in the following error message.
	WeightsUnpickler error: Unsupported global: GLOBAL omegaconf.dictconfig.DictConfig was not an allowed global by default. Please use `torch.serialization.add_safe_globals([omegaconf.dictconfig.DictConfig])` or the `torch.serialization.safe_globals([omegaconf.dictconfig.DictConfig])` context manager to allowlist this global if you trust this class/function.

Solution:

In this following line:

  File "/content/C.Origami/src/corigami/inference/utils/model_utils.py", line 25, in load_checkpoint
    checkpoint = torch.load(model_path, map_location=device)

change to checkpoint = torch.load(model_path, map_location=device, weights_only=False)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions