Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,9 +29,16 @@ from diffusers import (FluxPriorReduxPipeline, FluxInpaintPipeline, FluxFillPipe
|
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
import diffusers
|
| 36 |
|
| 37 |
|
|
@@ -49,7 +56,12 @@ base_model = "black-forest-labs/FLUX.1-dev"
|
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
-
txt2img_pipe = FluxPipeline.from_pretrained(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
txt2img_pipe = txt2img_pipe.to(device)
|
| 54 |
|
| 55 |
|
|
@@ -200,7 +212,12 @@ def run_lora(
|
|
| 200 |
print(f"skip invalid lora entry: {lora_info}")
|
| 201 |
continue
|
| 202 |
try:
|
| 203 |
-
weight_path = hf_hub_download(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
pipe.load_lora_weights(weight_path, adapter_name=adapter_name, prefix=None)
|
| 205 |
adapter_names.append(adapter_name)
|
| 206 |
adapter_weights.append(weight)
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
+
from huggingface_hub import login
|
| 33 |
+
|
| 34 |
+
HF_TOKEN = (os.getenv("HF_TOKEN") or os.getenv("HUGGINGFACEHUB_API_TOKEN") or "").strip()
|
| 35 |
+
|
| 36 |
+
if HF_TOKEN:
|
| 37 |
+
login(token=HF_TOKEN, add_to_git_credential=False)
|
| 38 |
+
print("✅ HF token found; logged in")
|
| 39 |
+
else:
|
| 40 |
+
print("⚠️ No HF token found. Public repos may work, gated/private models will fail.")
|
| 41 |
+
|
| 42 |
import diffusers
|
| 43 |
|
| 44 |
|
|
|
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
+
txt2img_pipe = FluxPipeline.from_pretrained(
|
| 60 |
+
base_model,
|
| 61 |
+
torch_dtype=dtype,
|
| 62 |
+
token=HF_TOKEN if HF_TOKEN else None,
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
txt2img_pipe = txt2img_pipe.to(device)
|
| 66 |
|
| 67 |
|
|
|
|
| 212 |
print(f"skip invalid lora entry: {lora_info}")
|
| 213 |
continue
|
| 214 |
try:
|
| 215 |
+
weight_path = hf_hub_download(
|
| 216 |
+
repo_id=repo,
|
| 217 |
+
filename=weights,
|
| 218 |
+
token=HF_TOKEN if HF_TOKEN else None,
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
pipe.load_lora_weights(weight_path, adapter_name=adapter_name, prefix=None)
|
| 222 |
adapter_names.append(adapter_name)
|
| 223 |
adapter_weights.append(weight)
|