vincentamato commited on
Commit
f24cfc2
·
1 Parent(s): 3c0699a

precache clip

Browse files
Files changed (2) hide show
  1. README.md +0 -2
  2. app.py +17 -0
README.md CHANGED
@@ -8,5 +8,3 @@ sdk_version: 5.38.0
8
  app_file: app.py
9
  pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
8
  app_file: app.py
9
  pinned: false
10
  ---
 
 
app.py CHANGED
@@ -93,6 +93,23 @@ for model_type, files in MODEL_FILES.items():
93
  print(f" Error with file {file}: {str(e)}")
94
  sys.stdout.flush()
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  print("\n" + "=" * 60)
97
  print("Model file preparation complete!")
98
  print("=" * 60)
 
93
  print(f" Error with file {file}: {str(e)}")
94
  sys.stdout.flush()
95
 
96
+ try:
97
+ print("\nPre-caching CLIP backbone (openai/clip-vit-large-patch14-336)…")
98
+ sys.stdout.flush()
99
+ from huggingface_hub import snapshot_download
100
+
101
+ snapshot_download(
102
+ repo_id="openai/clip-vit-large-patch14-336",
103
+ cache_dir=CACHE_DIR,
104
+ local_dir_use_symlinks=False, # make sure files are copied, not linked
105
+ resume_download=True,
106
+ )
107
+ print("CLIP checkpoint cached successfully!\n")
108
+ except Exception as clip_err:
109
+ print(f"Warning: failed to pre-cache CLIP model – it will download at runtime. ({clip_err})\n")
110
+ sys.stdout.flush()
111
+
112
+
113
  print("\n" + "=" * 60)
114
  print("Model file preparation complete!")
115
  print("=" * 60)