Spaces:
Runtime error
Runtime error
Aurel-test
commited on
Commit
·
7022682
1
Parent(s):
39a87a7
Fix model loading for CPU-only environments
Browse files
app.py
CHANGED
@@ -47,7 +47,9 @@ model = SegformerForSemanticSegmentation.from_pretrained(
|
|
47 |
label2id=label2id,
|
48 |
ignore_mismatched_sizes=True,
|
49 |
)
|
50 |
-
loaded_state_dict = torch.load(
|
|
|
|
|
51 |
model.load_state_dict(loaded_state_dict)
|
52 |
model = model.to(device)
|
53 |
model.eval()
|
|
|
47 |
label2id=label2id,
|
48 |
ignore_mismatched_sizes=True,
|
49 |
)
|
50 |
+
loaded_state_dict = torch.load(
|
51 |
+
state_dict_path, map_location=torch.device("cpu"), weights_only=True
|
52 |
+
)
|
53 |
model.load_state_dict(loaded_state_dict)
|
54 |
model = model.to(device)
|
55 |
model.eval()
|