anujithc commited on
Commit
ea1c146
·
verified ·
1 Parent(s): 494e322

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -5
app.py CHANGED
@@ -29,9 +29,16 @@ from diffusers import (FluxPriorReduxPipeline, FluxInpaintPipeline, FluxFillPipe
29
 
30
 
31
 
32
- # Login Hugging Face Hub
33
- HF_TOKEN = os.environ.get("HF_TOKEN")
34
- login(token=HF_TOKEN)
 
 
 
 
 
 
 
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(base_model, torch_dtype=dtype)
 
 
 
 
 
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(repo_id=repo, filename=weights)
 
 
 
 
 
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)