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
72686211
Unverified
Commit
72686211
authored
Nov 25, 2022
by
YosuaMichael
Committed by
GitHub
Nov 25, 2022
Browse files
Suppress warning when calling torch.frombuffer with non-writable buffer (#6971)
Co-authored-by:
Joao Gomes
<
jdsgomes@fb.com
>
parent
bfb474b9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
torchvision/io/_video_opt.py
torchvision/io/_video_opt.py
+12
-3
No files found.
torchvision/io/_video_opt.py
View file @
72686211
...
...
@@ -336,6 +336,9 @@ def _read_video_from_memory(
_validate_pts
(
audio_pts_range
)
if
not
isinstance
(
video_data
,
torch
.
Tensor
):
with
warnings
.
catch_warnings
():
# Ignore the warning because we actually dont modify the buffer in this function
warnings
.
filterwarnings
(
"ignore"
,
message
=
"The given buffer is not writable"
)
video_data
=
torch
.
frombuffer
(
video_data
,
dtype
=
torch
.
uint8
)
result
=
torch
.
ops
.
video_reader
.
read_video_from_memory
(
...
...
@@ -378,6 +381,9 @@ def _read_video_timestamps_from_memory(
is much faster than read_video(...)
"""
if
not
isinstance
(
video_data
,
torch
.
Tensor
):
with
warnings
.
catch_warnings
():
# Ignore the warning because we actually dont modify the buffer in this function
warnings
.
filterwarnings
(
"ignore"
,
message
=
"The given buffer is not writable"
)
video_data
=
torch
.
frombuffer
(
video_data
,
dtype
=
torch
.
uint8
)
result
=
torch
.
ops
.
video_reader
.
read_video_from_memory
(
video_data
,
...
...
@@ -416,6 +422,9 @@ def _probe_video_from_memory(
This function is torchscriptable
"""
if
not
isinstance
(
video_data
,
torch
.
Tensor
):
with
warnings
.
catch_warnings
():
# Ignore the warning because we actually dont modify the buffer in this function
warnings
.
filterwarnings
(
"ignore"
,
message
=
"The given buffer is not writable"
)
video_data
=
torch
.
frombuffer
(
video_data
,
dtype
=
torch
.
uint8
)
result
=
torch
.
ops
.
video_reader
.
probe_video_from_memory
(
video_data
)
vtimebase
,
vfps
,
vduration
,
atimebase
,
asample_rate
,
aduration
=
result
...
...
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