Skip to content

Commit 5c78a7a

Browse files
authored
Merge pull request #45 from mit-acl/feature/torch-support
add patch to support torch>2.4
2 parents 63d5ccb + 2a1c213 commit 5c78a7a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

roman/map/fastsam_wrapper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@
3838
logger = logging.getLogger(__name__)
3939
logger.setLevel(logging.WARN)
4040

41+
# Patch torch.load to disable weights_only loading for torch>2.4
42+
torch_version = torch.__version__.split('.')
43+
if int(torch_version[0]) > 2 or (int(torch_version[0]) == 2 and int(torch_version[1]) > 4):
44+
_real_torch_load = torch.load
45+
46+
def torch_load_no_weights_only(*args, **kwargs):
47+
kwargs["weights_only"] = False
48+
return _real_torch_load(*args, **kwargs)
49+
50+
torch.load = torch_load_no_weights_only
51+
4152
class FastSAMWrapper():
4253

4354
def __init__(self,

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
'shapely',
2828
'opencv-python>=4.6.0',
2929
'pyyaml',
30-
'torch==2.4.0',
31-
'torchvision==0.19.0',
30+
'torch>=2.4.0',
31+
'torchvision>=0.19.0',
3232
'fastsam @ git+https://github.com/CASIA-IVA-Lab/FastSAM.git@4d153e9',
3333
'robotdatapy>=1.1.0',
3434
'gdown',

0 commit comments

Comments
 (0)