Spaces:
Runtime error
Runtime error
use hf_hub_download
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import os
|
2 |
-
import json
|
3 |
|
4 |
import torch
|
5 |
import torch.nn.functional as F
|
@@ -8,14 +7,17 @@ from uniformer import uniformer_small
|
|
8 |
from imagenet_class_index import imagenet_classnames
|
9 |
|
10 |
import gradio as gr
|
|
|
11 |
|
12 |
# Device on which to run the model
|
13 |
# Set to cuda to load on GPU
|
14 |
device = "cpu"
|
15 |
-
os.system("wget https://cdn-lfs.huggingface.co/Andy1621/uniformer/fd192c31f8bd77670de8f171111bd51f56fd87e6aea45043ab2edc181e1fa775")
|
|
|
16 |
# Pick a pretrained model
|
17 |
model = uniformer_small()
|
18 |
-
state_dict = torch.load('fd192c31f8bd77670de8f171111bd51f56fd87e6aea45043ab2edc181e1fa775', map_location='cpu')
|
|
|
19 |
model.load_state_dict(state_dict['model'])
|
20 |
|
21 |
# Set to eval mode and move to desired device
|
|
|
1 |
import os
|
|
|
2 |
|
3 |
import torch
|
4 |
import torch.nn.functional as F
|
|
|
7 |
from imagenet_class_index import imagenet_classnames
|
8 |
|
9 |
import gradio as gr
|
10 |
+
from huggingface_hub import hf_hub_download
|
11 |
|
12 |
# Device on which to run the model
|
13 |
# Set to cuda to load on GPU
|
14 |
device = "cpu"
|
15 |
+
# os.system("wget https://cdn-lfs.huggingface.co/Andy1621/uniformer/fd192c31f8bd77670de8f171111bd51f56fd87e6aea45043ab2edc181e1fa775")
|
16 |
+
model_path = hf_hub_download(repo_id="https://huggingface.co/Andy1621/uniformer", filename="uniformer_small_in1k.pth")
|
17 |
# Pick a pretrained model
|
18 |
model = uniformer_small()
|
19 |
+
# state_dict = torch.load('fd192c31f8bd77670de8f171111bd51f56fd87e6aea45043ab2edc181e1fa775', map_location='cpu')
|
20 |
+
state_dict = torch.load(model_path, map_location='cpu')
|
21 |
model.load_state_dict(state_dict['model'])
|
22 |
|
23 |
# Set to eval mode and move to desired device
|