Suppress open_clip 'no pretrained weights' warning for LRSCLIP init

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
pikaliov
2026-04-21 18:26:59 +03:00
parent fa32b2e67f
commit a214320d81

View File

@@ -13,6 +13,7 @@ LRSCLIP (DGTRS-CLIP ViT-L-14) uses open_clip layout with KPS positional embeddin
import logging
import math
import warnings
from pathlib import Path
import coloredlogs
@@ -222,7 +223,12 @@ class LRSCLIPTextEncoder(nn.Module):
# Build the open_clip model to get correct architecture, then
# replace positional embedding and add KPS residual.
# Suppress "no pretrained weights" warning — we load DGTRS-CLIP weights after.
_root = logging.getLogger()
_prev_level = _root.level
_root.setLevel(logging.ERROR)
clip_model = open_clip.create_model("ViT-L-14", pretrained=None)
_root.setLevel(_prev_level)
# Extract text components.
self.token_embedding = clip_model.token_embedding