|
3 | 3 | from fractions import Fraction |
4 | 4 | from typing import List, Tuple |
5 | 5 |
|
6 | | -import numpy as np |
7 | 6 | import torch |
8 | 7 |
|
9 | 8 | from .._internally_replaced_utils import _get_extension_path |
@@ -338,7 +337,7 @@ def _read_video_from_memory( |
338 | 337 | _validate_pts(audio_pts_range) |
339 | 338 |
|
340 | 339 | if not isinstance(video_data, torch.Tensor): |
341 | | - video_data = torch.from_numpy(np.frombuffer(video_data, dtype=np.uint8)) |
| 340 | + video_data = torch.frombuffer(video_data, dtype=torch.uint8) |
342 | 341 |
|
343 | 342 | result = torch.ops.video_reader.read_video_from_memory( |
344 | 343 | video_data, |
@@ -378,7 +377,7 @@ def _read_video_timestamps_from_memory(video_data): |
378 | 377 | is much faster than read_video(...) |
379 | 378 | """ |
380 | 379 | if not isinstance(video_data, torch.Tensor): |
381 | | - video_data = torch.from_numpy(np.frombuffer(video_data, dtype=np.uint8)) |
| 380 | + video_data = torch.frombuffer(video_data, dtype=torch.uint8) |
382 | 381 | result = torch.ops.video_reader.read_video_from_memory( |
383 | 382 | video_data, |
384 | 383 | 0, # seek_frame_margin |
@@ -415,7 +414,7 @@ def _probe_video_from_memory(video_data): |
415 | 414 | This function is torchscriptable |
416 | 415 | """ |
417 | 416 | if not isinstance(video_data, torch.Tensor): |
418 | | - video_data = torch.from_numpy(np.frombuffer(video_data, dtype=np.uint8)) |
| 417 | + video_data = torch.frombuffer(video_data, dtype=torch.uint8) |
419 | 418 | result = torch.ops.video_reader.probe_video_from_memory(video_data) |
420 | 419 | vtimebase, vfps, vduration, atimebase, asample_rate, aduration = result |
421 | 420 | info = _fill_info(vtimebase, vfps, vduration, atimebase, asample_rate, aduration) |
|
0 commit comments