Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -252,7 +252,11 @@ def generate_storyboard_with_llm(user_prompt: str, n_shots: int, default_fps: in
|
|
| 252 |
USE_CUDA = torch.cuda.is_available()
|
| 253 |
DTYPE = torch.float16 if USE_CUDA else torch.float32
|
| 254 |
|
| 255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
|
| 257 |
_flux_t2i = None
|
| 258 |
_flux_i2i = None
|
|
@@ -262,21 +266,23 @@ def _lazy_flux_pipes():
|
|
| 262 |
global _flux_t2i, _flux_i2i
|
| 263 |
if _flux_t2i is not None and _flux_i2i is not None:
|
| 264 |
return _flux_t2i, _flux_i2i
|
| 265 |
-
_flux_t2i = FluxPipeline.from_pretrained(
|
|
|
|
|
|
|
| 266 |
if USE_CUDA: _flux_t2i = _flux_t2i.to("cuda")
|
| 267 |
-
_flux_i2i = FluxImg2ImgPipeline.from_pretrained(
|
|
|
|
|
|
|
| 268 |
if USE_CUDA: _flux_i2i = _flux_i2i.to("cuda")
|
| 269 |
return _flux_t2i, _flux_i2i
|
| 270 |
|
| 271 |
def _flux_healthcheck():
|
| 272 |
-
|
| 273 |
-
_lazy_flux_pipes()
|
| 274 |
-
return True
|
| 275 |
-
except Exception as e:
|
| 276 |
raise RuntimeError(
|
| 277 |
-
|
| 278 |
-
|
| 279 |
)
|
|
|
|
| 280 |
|
| 281 |
def _save_keyframe(pid: str, shot_id: int, img: Image.Image) -> str:
|
| 282 |
pdir = project_dir(pid)
|
|
|
|
| 252 |
USE_CUDA = torch.cuda.is_available()
|
| 253 |
DTYPE = torch.float16 if USE_CUDA else torch.float32
|
| 254 |
|
| 255 |
+
# ✅ Use a real FLUX repo instead of Nano
|
| 256 |
+
FLUX_MODEL = os.getenv("FLUX_MODEL", "black-forest-labs/FLUX.1-schnell")
|
| 257 |
+
|
| 258 |
+
# ✅ Add token support
|
| 259 |
+
HF_TOKEN = os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACE_HUB_TOKEN")
|
| 260 |
|
| 261 |
_flux_t2i = None
|
| 262 |
_flux_i2i = None
|
|
|
|
| 266 |
global _flux_t2i, _flux_i2i
|
| 267 |
if _flux_t2i is not None and _flux_i2i is not None:
|
| 268 |
return _flux_t2i, _flux_i2i
|
| 269 |
+
_flux_t2i = FluxPipeline.from_pretrained(
|
| 270 |
+
FLUX_MODEL, torch_dtype=DTYPE, use_safetensors=True, token=HF_TOKEN
|
| 271 |
+
)
|
| 272 |
if USE_CUDA: _flux_t2i = _flux_t2i.to("cuda")
|
| 273 |
+
_flux_i2i = FluxImg2ImgPipeline.from_pretrained(
|
| 274 |
+
FLUX_MODEL, torch_dtype=DTYPE, use_safetensors=True, token=HF_TOKEN
|
| 275 |
+
)
|
| 276 |
if USE_CUDA: _flux_i2i = _flux_i2i.to("cuda")
|
| 277 |
return _flux_t2i, _flux_i2i
|
| 278 |
|
| 279 |
def _flux_healthcheck():
|
| 280 |
+
if not HF_TOKEN:
|
|
|
|
|
|
|
|
|
|
| 281 |
raise RuntimeError(
|
| 282 |
+
"HF_TOKEN is not set. FLUX models are gated; set a Hugging Face READ token "
|
| 283 |
+
"and accept the model terms on the repo page."
|
| 284 |
)
|
| 285 |
+
_lazy_flux_pipes()
|
| 286 |
|
| 287 |
def _save_keyframe(pid: str, shot_id: int, img: Image.Image) -> str:
|
| 288 |
pdir = project_dir(pid)
|