MojoHz commited on
Commit
d45dac8
·
verified ·
1 Parent(s): 06d8dfd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -1,4 +1,22 @@
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
 
4
  import torch
 
1
 
2
+ import os
3
+ import subprocess
4
+
5
+ # Ensure the required library is installed
6
+ try:
7
+ import huggingface_hub
8
+ except ImportError:
9
+ subprocess.run(["pip", "install", "huggingface_hub"])
10
+
11
+ # Access Hugging Face token from environment variables
12
+ hf_token = os.getenv("HF_TOKEN")
13
+ if not hf_token:
14
+ raise ValueError("Hugging Face token not found. Please set it as an environment variable.")
15
+
16
+ # Log in programmatically
17
+ from huggingface_hub import login
18
+ login(token=hf_token)
19
+ print("Successfully logged in to Hugging Face!")
20
 
21
 
22
  import torch