Skip to content

Commit 1b01224

Browse files
committed
Remove safeglobals add, not worth having with all pretrained weights on hub and numpy 1 vs 2 issues
1 parent 84f7d2f commit 1b01224

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

src/open_clip/factory.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010

1111
import torch
1212

13-
from .constants import OPENAI_DATASET_MEAN, OPENAI_DATASET_STD
1413
from .convert import convert_state_dict
1514
from .model import CLIP, CustomTextCLIP, convert_weights_to_lp, convert_to_custom_text_state_dict,\
1615
resize_pos_embed, get_cast_dtype, resize_text_pos_embed, set_model_preprocess_cfg
1716
from .coca_model import CoCa
1817
from .loss import ClipLoss, DistillClipLoss, CoCaLoss, SigLipLoss
19-
from .openai import load_openai_model
2018
from .pretrained import is_pretrained_cfg, get_pretrained_cfg, download_pretrained,\
2119
list_pretrained_tags_by_model, download_pretrained_from_hf
2220
from .transform import image_transform_v2, AugmentationCfg, PreprocessCfg, merge_preprocess_dict, merge_preprocess_kwargs
@@ -27,20 +25,6 @@
2725
_MODEL_CONFIGS = {} # directory (model_name: config) of model architecture configs
2826

2927

30-
try:
31-
import _codecs
32-
import numpy as np
33-
# add safe globals that are known to be needed for metaclip weights loading in weights_only=True mode
34-
torch.serialization.add_safe_globals([
35-
_codecs.encode, # this one not needed for PyTorch >= 2.5.0
36-
np.core.multiarray.scalar,
37-
np.dtype,
38-
np.dtypes.Float64DType,
39-
])
40-
except Exception:
41-
pass
42-
43-
4428
def _natural_key(string_):
4529
return [int(s) if s.isdigit() else s for s in re.split(r'(\d+)', string_.lower())]
4630

0 commit comments

Comments
 (0)