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()