Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -3,13 +3,15 @@ import torch
|
|
3 |
import spaces
|
4 |
from transformers import AutoModel
|
5 |
|
|
|
|
|
6 |
@spaces.GPU
|
7 |
def get_model_summary(model_name):
|
8 |
# Check if CUDA is available and set the device accordingly
|
9 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
10 |
|
11 |
# Load the model and move it to the selected device
|
12 |
-
model = AutoModel.from_pretrained(model_name).to(device)
|
13 |
|
14 |
# Return the model's architecture as a string
|
15 |
return str(model)
|
|
|
3 |
import spaces
|
4 |
from transformers import AutoModel
|
5 |
|
6 |
+
hf_token = os.getenv("HF_TOKEN")
|
7 |
+
|
8 |
@spaces.GPU
|
9 |
def get_model_summary(model_name):
|
10 |
# Check if CUDA is available and set the device accordingly
|
11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
12 |
|
13 |
# Load the model and move it to the selected device
|
14 |
+
model = AutoModel.from_pretrained(model_name, hf_token=hf_token).to(device)
|
15 |
|
16 |
# Return the model's architecture as a string
|
17 |
return str(model)
|