Spaces:
Sleeping
Sleeping
File size: 829 Bytes
49c4c8c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import os
from transformers import CLIPProcessor, CLIPModel
# Define where we want to save the model locally
MODEL_PATH = "./local_clip_model"
def download_and_save_model():
print("⏳ Downloading OpenAI CLIP model... (This may take a minute)")
model_name = "openai/clip-vit-base-patch32"
# Download Model and Processor
model = CLIPModel.from_pretrained(model_name)
processor = CLIPProcessor.from_pretrained(model_name)
# Save them to the local directory
if not os.path.exists(MODEL_PATH):
os.makedirs(MODEL_PATH)
model.save_pretrained(MODEL_PATH)
processor.save_pretrained(MODEL_PATH)
print(f"✅ Model successfully saved to '{MODEL_PATH}'")
print("You can now run the project offline.")
if __name__ == "__main__":
download_and_save_model() |