smartdigitalnetworks commited on
Commit
0e482f0
·
verified ·
1 Parent(s): f01e144

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -21
app.py CHANGED
@@ -252,40 +252,32 @@ def get_hub_or_local_checkpoint(repo_id: str, filename: str):
252
  return ckpt_path
253
 
254
  def download_gemma_model(repo_id: str):
255
- """
256
- Download the whole repo into a normal app folder instead of ~/.cache/huggingface.
257
- """
258
- local_repo_dir = MODEL_DIR / repo_id.replace("/", "__")
259
- local_repo_dir.mkdir(parents=True, exist_ok=True)
260
-
261
- log_event(f"Downloading Gemma model from {repo_id} into {local_repo_dir}...")
262
- local_dir = snapshot_download(
263
- repo_id=repo_id,
264
- local_dir=local_repo_dir,
265
- )
266
- log_event(f"Gemma model downloaded to {local_dir}")
267
  return local_dir
268
 
269
  # Initialize model ledger and text encoder at startup (load once, keep in memory)
270
- log_event("=" * 80)
271
- log_event("Loading Gemma Text Encoder...")
272
- log_event("=" * 80)
273
 
274
  checkpoint_path = get_hub_or_local_checkpoint(DEFAULT_REPO_ID, DEFAULT_CHECKPOINT_FILENAME)
275
  gemma_local_path = download_gemma_model(DEFAULT_GEMMA_REPO_ID)
276
- device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
277
 
278
- log_event(f"Initializing text encoder with:")
279
- log_event(f" checkpoint_path={checkpoint_path}")
280
- log_event(f" gemma_root={gemma_local_path}")
281
- log_event(f" device={device}")
282
 
283
 
284
  model_ledger = ModelLedger(
285
  dtype=torch.bfloat16,
286
  device=device,
287
  checkpoint_path=checkpoint_path,
288
- gemma_root_path=gemma_local_path,
289
  local_files_only=False
290
  )
291
 
 
252
  return ckpt_path
253
 
254
  def download_gemma_model(repo_id: str):
255
+ """Download the full Gemma model directory."""
256
+ print(f"Downloading Gemma model from {repo_id}...")
257
+ local_dir = snapshot_download(repo_id=repo_id)
258
+ print(f"Gemma model downloaded to {local_dir}")
 
 
 
 
 
 
 
 
259
  return local_dir
260
 
261
  # Initialize model ledger and text encoder at startup (load once, keep in memory)
262
+ print("=" * 80)
263
+ print("Loading Gemma Text Encoder...")
264
+ print("=" * 80)
265
 
266
  checkpoint_path = get_hub_or_local_checkpoint(DEFAULT_REPO_ID, DEFAULT_CHECKPOINT_FILENAME)
267
  gemma_local_path = download_gemma_model(DEFAULT_GEMMA_REPO_ID)
268
+ device = "cuda"
269
 
270
+ print(f"Initializing text encoder with:")
271
+ print(f" checkpoint_path={checkpoint_path}")
272
+ print(f" gemma_root={gemma_local_path}")
273
+ print(f" device={device}")
274
 
275
 
276
  model_ledger = ModelLedger(
277
  dtype=torch.bfloat16,
278
  device=device,
279
  checkpoint_path=checkpoint_path,
280
+ gemma_root_path=DEFAULT_GEMMA_REPO_ID,
281
  local_files_only=False
282
  )
283