Spaces:
Running on Zero
Running on Zero
Fix torch>=2.6 weights_only default breaking checkpoint loads (pose estimator etc.)
Browse files
app.py
CHANGED
|
@@ -30,6 +30,14 @@ import base64
|
|
| 30 |
import spaces
|
| 31 |
import torch
|
| 32 |
torch._dynamo.config.disable = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
import subprocess
|
| 34 |
import os
|
| 35 |
import argparse
|
|
|
|
| 30 |
import spaces
|
| 31 |
import torch
|
| 32 |
torch._dynamo.config.disable = True
|
| 33 |
+
|
| 34 |
+
# torch>=2.6 flipped torch.load's default to weights_only=True, which breaks loading
|
| 35 |
+
# these (trusted, first-party) checkpoints that pickle argparse.Namespace and other globals.
|
| 36 |
+
_orig_torch_load = torch.load
|
| 37 |
+
def _torch_load_full(*args, **kwargs):
|
| 38 |
+
kwargs.setdefault("weights_only", False)
|
| 39 |
+
return _orig_torch_load(*args, **kwargs)
|
| 40 |
+
torch.load = _torch_load_full
|
| 41 |
import subprocess
|
| 42 |
import os
|
| 43 |
import argparse
|