GPU hack fixes image res
Browse files
images.py
CHANGED
|
@@ -7,13 +7,17 @@ One model, one `image=` parameter does both jobs:
|
|
| 7 |
Shared art_style + a fixed per-adventure seed give every quest a cohesive look. Always EDIT
|
| 8 |
the initial image for success/failure states (consistency) - never text-to-image from scratch.
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
| 12 |
"""
|
| 13 |
from __future__ import annotations
|
| 14 |
|
| 15 |
import base64
|
| 16 |
import io
|
|
|
|
| 17 |
|
| 18 |
import spaces
|
| 19 |
import torch
|
|
|
|
| 7 |
Shared art_style + a fixed per-adventure seed give every quest a cohesive look. Always EDIT
|
| 8 |
the initial image for success/failure states (consistency) - never text-to-image from scratch.
|
| 9 |
|
| 10 |
+
Loading happens at MODULE LEVEL (startup), incl. `.to("cuda")`. Outside @spaces.GPU, ZeroGPU
|
| 11 |
+
runs a CUDA-emulation mode, so the placement is recorded now and realized on the real GPU when
|
| 12 |
+
it attaches per call. This keeps the ~13GB load OFF the metered GPU clock (the @spaces.GPU call
|
| 13 |
+
only pays for inference) and is the pattern HF recommends — lazy-loading inside the call is
|
| 14 |
+
"significantly less efficient" (and made every generation slow).
|
| 15 |
"""
|
| 16 |
from __future__ import annotations
|
| 17 |
|
| 18 |
import base64
|
| 19 |
import io
|
| 20 |
+
import os
|
| 21 |
|
| 22 |
import spaces
|
| 23 |
import torch
|