copilot-swe-agent[bot] matheus-rech commited on
Commit
186cf0b
·
1 Parent(s): 76a8cf4

Fix HF_TOKEN handling to prevent interactive password prompt

Browse files

Co-authored-by: matheus-rech <71096630+matheus-rech@users.noreply.github.com>

Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -45,13 +45,13 @@ if not hf_token:
45
  print("⚠️ WARNING: HF_TOKEN environment variable not set!")
46
  print("⚠️ Some features may not work. Please set HF_TOKEN in Space settings.")
47
  hf_token = None # Allow app to start, but model loading will fail gracefully
48
-
49
- # Login to Hugging Face Hub
50
- try:
51
- from huggingface_hub import login
52
- login(token=hf_token, add_to_git_credential=False)
53
- except Exception as e:
54
- print(f"⚠️ Could not login to HF Hub (non-critical): {e}")
55
 
56
  # Load SAM 3 Model
57
  print("🧠 Loading SAM 3 Model...")
 
45
  print("⚠️ WARNING: HF_TOKEN environment variable not set!")
46
  print("⚠️ Some features may not work. Please set HF_TOKEN in Space settings.")
47
  hf_token = None # Allow app to start, but model loading will fail gracefully
48
+ else:
49
+ # Login to Hugging Face Hub (only if token is provided)
50
+ try:
51
+ from huggingface_hub import login
52
+ login(token=hf_token, add_to_git_credential=False)
53
+ except Exception as e:
54
+ print(f"⚠️ Could not login to HF Hub (non-critical): {e}")
55
 
56
  # Load SAM 3 Model
57
  print("🧠 Loading SAM 3 Model...")