#!/usr/bin/env python3 """Probe the REAL google/tipsv2-b14 interface on CPU (no GPU use). Prints: param counts (vision/text/total), encode_image output fields and shapes at 224x224, text interface outputs (encode_text / get_text_features), num_register_tokens. Mirrors the loading path used by SERA (AutoModel.from_pretrained, trust_remote_code=True, local_files_only=True). """ import torch from transformers import AutoModel torch.manual_seed(0) model = AutoModel.from_pretrained( "google/tipsv2-b14", trust_remote_code=True, local_files_only=True ) model.eval() def nparams(mod): return sum(p.numel() for p in mod.parameters()) ve = model.vision_encoder te = model.text_encoder print("vision params:", nparams(ve)) print("text params:", nparams(te)) print("total params:", nparams(model)) print("num_register_tokens:", getattr(ve, "num_register_tokens", None)) img = torch.rand(2, 3, 224, 224) with torch.no_grad(): out = model.encode_image(img) print("encode_image type:", type(out).__name__) for field in ("cls_token", "register_tokens", "patch_tokens"): v = getattr(out, field, None) print(f" {field}:", None if v is None else tuple(v.shape)) # Text: public interface candidates texts = ["pick up the milk and place it in the basket", "Execute the task shown in the video."] for name in ("encode_text", "get_text_features"): fn = getattr(model, name, None) print(f"{name}:", "present" if fn is not None else "ABSENT") if fn is not None: try: with torch.no_grad(): r = fn(texts) if isinstance(r, torch.Tensor): print(f" -> tensor {tuple(r.shape)}") else: print(" -> type:", type(r).__name__) for field in ("text_embedding", "pooled_output", "last_hidden_state", "cls_token", "embedding"): v = getattr(r, field, None) if v is not None: print(f" {field}:", tuple(v.shape) if isinstance(v, torch.Tensor) else type(v).__name__) except Exception as e: # noqa: BLE001 print(" -> ERROR:", type(e).__name__, str(e)[:300]) print("has _tokenizer attr:", hasattr(model, "_tokenizer")) print("has _load_tokenizer:", hasattr(model, "_load_tokenizer"))