Daankular commited on
Commit
54834e1
·
verified ·
1 Parent(s): dbad3aa

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -17,7 +17,7 @@ import cv2
17
  import numpy as np
18
  import torch
19
  import torch._dynamo
20
- from huggingface_hub import snapshot_download, login as hf_login
21
  import huggingface_hub.constants as _hf_const
22
  if not hasattr(_hf_const, "HF_HUB_ENABLE_HF_TRANSFER"):
23
  _hf_const.HF_HUB_ENABLE_HF_TRANSFER = False
@@ -69,8 +69,11 @@ except Exception as _e:
69
  # Space restarts without re-downloading.
70
  LORA_DIR = Path("/data/loras")
71
  HF_TOKEN = os.environ.get("HF_TOKEN", "")
 
 
72
  if HF_TOKEN:
73
- hf_login(token=HF_TOKEN)
 
74
 
75
  # Delete the old lkzd7 LoRA directory if it still exists — it consumed 15-20 GB
76
  # of storage and contained no identity-preserving LoRAs.
@@ -341,12 +344,10 @@ _aoti_saved: list[tuple] = []
341
  def _init_pipeline():
342
  global pipe, original_scheduler, _aoti_saved
343
 
344
- # Re-authenticate inside the GPU worker the login from startup may not
345
- # carry into this process context.
346
  if HF_TOKEN:
347
  os.environ["HF_TOKEN"] = HF_TOKEN
348
  os.environ["HUGGING_FACE_HUB_TOKEN"] = HF_TOKEN
349
- hf_login(token=HF_TOKEN)
350
 
351
  print(f"Loading pipeline: {MODEL_ID}")
352
  pipe = WanImageToVideoPipeline.from_pretrained(
 
17
  import numpy as np
18
  import torch
19
  import torch._dynamo
20
+ from huggingface_hub import snapshot_download
21
  import huggingface_hub.constants as _hf_const
22
  if not hasattr(_hf_const, "HF_HUB_ENABLE_HF_TRANSFER"):
23
  _hf_const.HF_HUB_ENABLE_HF_TRANSFER = False
 
69
  # Space restarts without re-downloading.
70
  LORA_DIR = Path("/data/loras")
71
  HF_TOKEN = os.environ.get("HF_TOKEN", "")
72
+ # Set both env-var spellings so all HF libraries pick up the token
73
+ # without needing to call login() (which hits whoami and gets rate-limited).
74
  if HF_TOKEN:
75
+ os.environ["HF_TOKEN"] = HF_TOKEN
76
+ os.environ["HUGGING_FACE_HUB_TOKEN"] = HF_TOKEN
77
 
78
  # Delete the old lkzd7 LoRA directory if it still exists — it consumed 15-20 GB
79
  # of storage and contained no identity-preserving LoRAs.
 
344
  def _init_pipeline():
345
  global pipe, original_scheduler, _aoti_saved
346
 
347
+ # Ensure token env-vars are set in this worker context.
 
348
  if HF_TOKEN:
349
  os.environ["HF_TOKEN"] = HF_TOKEN
350
  os.environ["HUGGING_FACE_HUB_TOKEN"] = HF_TOKEN
 
351
 
352
  print(f"Loading pipeline: {MODEL_ID}")
353
  pipe = WanImageToVideoPipeline.from_pretrained(