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
893b4abd
Unverified
Commit
893b4abd
authored
Nov 20, 2023
by
Nicolas Hug
Committed by
GitHub
Nov 20, 2023
Browse files
Remove deprecated path parameter to VideoReader and made src mandatory (#8125)
Co-authored-by:
vfdev
<
vfdev.5@gmail.com
>
parent
127e8a70
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
17 deletions
+13
-17
test/test_videoapi.py
test/test_videoapi.py
+8
-0
torchvision/io/video_reader.py
torchvision/io/video_reader.py
+5
-17
No files found.
test/test_videoapi.py
View file @
893b4abd
...
...
@@ -299,6 +299,14 @@ class TestVideoApi:
for
i
in
range
(
len
(
av_keyframes
)):
assert
av_keyframes
[
i
]
==
approx
(
vr_keyframes
[
i
],
rel
=
0.001
)
def
test_src
(
self
):
with
pytest
.
raises
(
ValueError
,
match
=
"src cannot be empty"
):
VideoReader
(
src
=
""
)
with
pytest
.
raises
(
ValueError
,
match
=
"src must be either string"
):
VideoReader
(
src
=
2
)
with
pytest
.
raises
(
TypeError
,
match
=
"unexpected keyword argument"
):
VideoReader
(
path
=
"path"
)
if
__name__
==
"__main__"
:
pytest
.
main
([
__file__
])
torchvision/io/video_reader.py
View file @
893b4abd
import
io
import
warnings
from
typing
import
Any
,
Dict
,
Iterator
,
Optional
from
typing
import
Any
,
Dict
,
Iterator
import
torch
...
...
@@ -102,8 +102,6 @@ class VideoReader:
If Tensor, it is interpreted internally as byte buffer.
It must be one-dimensional, of type ``torch.uint8``.
stream (string, optional): descriptor of the required stream, followed by the stream id,
in the format ``{stream_type}:{stream_id}``. Defaults to ``"video:0"``.
Currently available options include ``['video', 'audio']``
...
...
@@ -111,31 +109,21 @@ class VideoReader:
num_threads (int, optional): number of threads used by the codec to decode video.
Default value (0) enables multithreading with codec-dependent heuristic. The performance
will depend on the version of FFMPEG codecs supported.
path (str, optional):
.. warning:
This parameter was deprecated in ``0.15`` and will be removed in ``0.17``.
Please use ``src`` instead.
"""
def
__init__
(
self
,
src
:
str
=
""
,
src
:
str
,
stream
:
str
=
"video"
,
num_threads
:
int
=
0
,
path
:
Optional
[
str
]
=
None
,
)
->
None
:
_log_api_usage_once
(
self
)
from
..
import
get_video_backend
self
.
backend
=
get_video_backend
()
if
isinstance
(
src
,
str
):
if
src
==
""
:
if
path
is
None
:
raise
TypeError
(
"src cannot be empty"
)
src
=
path
warnings
.
warn
(
"path is deprecated and will be removed in 0.17. Please use src instead"
)
if
not
src
:
raise
ValueError
(
"src cannot be empty"
)
elif
isinstance
(
src
,
bytes
):
if
self
.
backend
in
[
"cuda"
]:
raise
RuntimeError
(
...
...
@@ -154,7 +142,7 @@ class VideoReader:
"VideoReader cannot be initialized from Tensor object when using cuda or pyav backend."
)
else
:
raise
Typ
eError
(
"
`
src
`
must be either string, Tensor or bytes object."
)
raise
Valu
eError
(
f
"src must be either string, Tensor or bytes object.
Got
{
type
(
src
)
}
"
)
if
self
.
backend
==
"cuda"
:
device
=
torch
.
device
(
"cuda"
)
...
...
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