Spaces:
Runtime error
Runtime error
Update run_inference.py
Browse files- run_inference.py +9 -0
run_inference.py
CHANGED
|
@@ -2,6 +2,13 @@ import sys, os
|
|
| 2 |
import cv2
|
| 3 |
import torch
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Allow unpickling of HistoryBuffer
|
| 6 |
from mmengine.logging.history_buffer import HistoryBuffer
|
| 7 |
# Allow numpy reconstruct, ndarray, dtype, Float64DType, Int64DType, and getattr
|
|
@@ -10,6 +17,8 @@ import numpy.core.multiarray as cam
|
|
| 10 |
import numpy.dtypes as dtypes
|
| 11 |
|
| 12 |
torch.serialization.add_safe_globals([
|
|
|
|
|
|
|
| 13 |
HistoryBuffer,
|
| 14 |
cam._reconstruct,
|
| 15 |
np.ndarray,
|
|
|
|
| 2 |
import cv2
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
# Monkey-patch torch.load to disable weights_only safety for trusted checkpoint
|
| 6 |
+
_orig_torch_load = torch.load
|
| 7 |
+
torch.load = lambda f, **kwargs: _orig_torch_load(f, weights_only=False, **kwargs)
|
| 8 |
+
|
| 9 |
+
import cv2
|
| 10 |
+
import torch
|
| 11 |
+
|
| 12 |
# Allow unpickling of HistoryBuffer
|
| 13 |
from mmengine.logging.history_buffer import HistoryBuffer
|
| 14 |
# Allow numpy reconstruct, ndarray, dtype, Float64DType, Int64DType, and getattr
|
|
|
|
| 17 |
import numpy.dtypes as dtypes
|
| 18 |
|
| 19 |
torch.serialization.add_safe_globals([
|
| 20 |
+
cam.scalar, # allow numpy scalar types
|
| 21 |
+
|
| 22 |
HistoryBuffer,
|
| 23 |
cam._reconstruct,
|
| 24 |
np.ndarray,
|