kayte0342 commited on
Commit
aa3cffe
·
verified ·
1 Parent(s): 9a31ffb

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -15,13 +15,24 @@ import time
15
 
16
 
17
  # --- Install huggingface_hub[cli] ---
18
- # This will ensure that the CLI extras are installed.
19
- # (If the package is already installed, pip will simply verify the installation.)
20
  subprocess.run("pip install huggingface_hub[cli]", shell=True, check=True)
21
 
 
 
22
  from huggingface_hub import login, hf_hub_download, HfFileSystem, ModelCard, snapshot_download
23
 
24
- huggingface-cli login
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  # Load LoRAs from JSON file
27
  with open('loras.json', 'r') as f:
 
15
 
16
 
17
  # --- Install huggingface_hub[cli] ---
 
 
18
  subprocess.run("pip install huggingface_hub[cli]", shell=True, check=True)
19
 
20
+ # --- Authenticate to Hugging Face ---
21
+ # Try to get the token from the environment; if not found, prompt for it manually.
22
  from huggingface_hub import login, hf_hub_download, HfFileSystem, ModelCard, snapshot_download
23
 
24
+ hf_token = os.environ.get("HF_TOKEN")
25
+ if not hf_token:
26
+ hf_token = input("Enter your Hugging Face token: ").strip()
27
+ # Optionally, you can set the token as an environment variable for the remainder of the session:
28
+ os.environ["HF_TOKEN"] = hf_token
29
+
30
+ if hf_token:
31
+ login(hf_token)
32
+ print("Successfully authenticated to Hugging Face.")
33
+ else:
34
+ print("No token provided. Some features may not work without authentication.")
35
+
36
 
37
  # Load LoRAs from JSON file
38
  with open('loras.json', 'r') as f: