From fa2cca056c96d560077bce4ef935585733399315 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Wed, 14 Jun 2023 12:57:02 -0400 Subject: [PATCH] Don't initialize CLIPVision weights to default values. --- comfy/clip_vision.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/comfy/clip_vision.py b/comfy/clip_vision.py index efb2d538..a95707e4 100644 --- a/comfy/clip_vision.py +++ b/comfy/clip_vision.py @@ -1,4 +1,4 @@ -from transformers import CLIPVisionModelWithProjection, CLIPVisionConfig, CLIPImageProcessor +from transformers import CLIPVisionModelWithProjection, CLIPVisionConfig, CLIPImageProcessor, modeling_utils from .utils import load_torch_file, transformers_convert import os import torch @@ -6,7 +6,8 @@ import torch class ClipVisionModel(): def __init__(self, json_config): config = CLIPVisionConfig.from_json_file(json_config) - self.model = CLIPVisionModelWithProjection(config) + with modeling_utils.no_init_weights(): + self.model = CLIPVisionModelWithProjection(config) self.processor = CLIPImageProcessor(crop_size=224, do_center_crop=True, do_convert_rgb=True,