Update app.py
Browse files
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
|