YueLiao / CDN

Code for "Mining the Benefits of Two-stage and One-stage HOI Detection"
Apache License 2.0
89 stars 15 forks source link

ImportError: cannot import name '_new_empty_tensor' from 'torchvision.ops' #24

Closed Dawn-LX closed 1 year ago

Dawn-LX commented 1 year ago

A small tip, in case the future researcher have the similar issue.

my torchvision.__version__ is "0.12.0+cu113" and this line https://github.com/YueLiao/CDN/blob/71c570296ecc7194c7abf99f5207344aa9c8dabe/util/misc.py#L14

should be modified as:

# if float(torchvision.__version__[:3]) < 0.7:
if int(torchvision.__version__.split('.')[1]) < 7:  # my torchvision.__version__ is "0.12.0+cu113"
    from torchvision.ops import _new_empty_tensor
    from torchvision.ops.misc import _output_size
YueLiao commented 1 year ago

Yes, that's right.