Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
7a36388c
Unverified
Commit
7a36388c
authored
Mar 17, 2020
by
NVS Abhilash
Committed by
GitHub
Mar 17, 2020
Browse files
replace imp with importlib (fixes #1607) (#1976)
Co-authored-by:
Francisco Massa
<
fvsmassa@gmail.com
>
parent
32e16805
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
torchvision/extension.py
torchvision/extension.py
+11
-3
torchvision/io/_video_opt.py
torchvision/io/_video_opt.py
+12
-4
No files found.
torchvision/extension.py
View file @
7a36388c
...
...
@@ -3,13 +3,21 @@ _HAS_OPS = False
def
_register_extensions
():
import
os
import
imp
import
imp
ortlib
import
torch
# load the custom_op_library and register the custom ops
lib_dir
=
os
.
path
.
dirname
(
__file__
)
_
,
path
,
_
=
imp
.
find_module
(
"_C"
,
[
lib_dir
])
torch
.
ops
.
load_library
(
path
)
loader_details
=
(
importlib
.
machinery
.
ExtensionFileLoader
,
importlib
.
machinery
.
EXTENSION_SUFFIXES
)
extfinder
=
importlib
.
machinery
.
FileFinder
(
lib_dir
,
loader_details
)
ext_specs
=
extfinder
.
find_spec
(
"_C"
)
if
ext_specs
is
None
:
raise
ImportError
torch
.
ops
.
load_library
(
ext_specs
.
origin
)
try
:
...
...
torchvision/io/_video_opt.py
View file @
7a36388c
import
imp
import
imp
ortlib
import
math
import
os
import
warnings
...
...
@@ -14,9 +14,17 @@ _HAS_VIDEO_OPT = False
try
:
lib_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
".."
)
_
,
path
,
description
=
imp
.
find_module
(
"video_reader"
,
[
lib_dir
])
torch
.
ops
.
load_library
(
path
)
_HAS_VIDEO_OPT
=
True
loader_details
=
(
importlib
.
machinery
.
ExtensionFileLoader
,
importlib
.
machinery
.
EXTENSION_SUFFIXES
)
extfinder
=
importlib
.
machinery
.
FileFinder
(
lib_dir
,
loader_details
)
ext_specs
=
extfinder
.
find_spec
(
"video_reader"
)
if
ext_specs
is
not
None
:
torch
.
ops
.
load_library
(
ext_specs
.
origin
)
_HAS_VIDEO_OPT
=
True
except
(
ImportError
,
OSError
):
pass
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment