multimodalart HF Staff commited on
Commit
a37fca8
·
verified ·
1 Parent(s): c74821f

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -27,13 +27,26 @@ MODEL_NICKNAME = "core" # ARDY-Core-RP-20FPS-Horizon40, 27-joint skeleton @ 20
27
  MAX_SEED = 2**31 - 1
28
 
29
  # -----------------------------------------------------------------------------
30
- # Model loading (module scope, eager .to("cuda") per ZeroGPU rules)
 
 
 
 
 
 
31
  # -----------------------------------------------------------------------------
32
- print("Loading ARDY text encoder (LLM2Vec-Llama-3-8B)…", flush=True)
33
- _text_encoder = load_text_encoder(mode="local", device="cuda")
34
-
35
- print("Loading ARDY motion model…", flush=True)
36
- MODEL = load_model(MODEL_NICKNAME, device="cuda", text_encoder=_text_encoder)
 
 
 
 
 
 
 
37
  MODEL = MODEL.eval()
38
 
39
  FPS = float(MODEL.motion_rep.fps)
 
27
  MAX_SEED = 2**31 - 1
28
 
29
  # -----------------------------------------------------------------------------
30
+ # Model loading (module scope).
31
+ #
32
+ # ZeroGPU has no live GPU at startup: it intercepts .to("cuda") *placement* but
33
+ # NOT arbitrary CUDA compute. LLM2Vec's PEFT load runs a LoRA `merge_and_unload`
34
+ # (real matmuls), so we build everything on CPU first, then .to("cuda") — the
35
+ # placement call is what the ZeroGPU hijack packs to disk and streams into VRAM
36
+ # on the first @spaces.GPU request.
37
  # -----------------------------------------------------------------------------
38
+ print("Loading ARDY text encoder (LLM2Vec-Llama-3-8B) on CPU…", flush=True)
39
+ _text_encoder = load_text_encoder(mode="local", device="cpu")
40
+
41
+ print("Loading ARDY motion model on CPU…", flush=True)
42
+ MODEL = load_model(MODEL_NICKNAME, device="cpu", text_encoder=_text_encoder)
43
+
44
+ print("Moving models to CUDA (ZeroGPU-intercepted placement)…", flush=True)
45
+ _text_encoder = _text_encoder.to("cuda")
46
+ MODEL = MODEL.to("cuda")
47
+ # self.device was captured at construction (device="cpu"); generation creates
48
+ # many tensors on it, so retarget it to cuda to match the moved weights.
49
+ MODEL.device = "cuda"
50
  MODEL = MODEL.eval()
51
 
52
  FPS = float(MODEL.motion_rep.fps)