Created
June 2, 2025 16:38
-
-
Save jacobsapps/d6a81a41ac18c7f6699f89fc6762e45d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import json | |
import numpy as np | |
import coremltools as ct | |
from transformers import CLIPTokenizer | |
# 1. Load labels | |
with open("stats.txt", "r") as f: | |
categories = [line.strip() for line in f if line.strip()] | |
# 2. Load CLIP-compatible tokenizer | |
tokenizer = CLIPTokenizer.from_pretrained("openai/clip-vit-base-patch32") | |
# 3. Process embeddings | |
model_path = os.path.join( | |
"mobileclip_blt_text.mlpackage", | |
"Data", | |
"com.apple.CoreML", | |
"model.mlmodel" | |
) | |
# 4. Validate model path | |
if not os.path.isfile(model_path): | |
raise FileNotFoundError(f"❌ model.mlmodel not found at: {model_path}") | |
print(f"📦 Loading model: {model_path}") | |
model = ct.models.MLModel(model_path) | |
entries = [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment