dlwpt-code icon indicating copy to clipboard operation
dlwpt-code copied to clipboard

TypeError: empty(): argument 'size' must be tuple of ints, but found element of type float at pos 2

Open vokhidovhusan opened this issue 3 years ago • 3 comments

Hi @elistevens I am trying X_video_cockatoo.ipynb but I got an error as following:

TypeError                                 Traceback (most recent call last)
<ipython-input-11-9d9b6563e3ec> in <module>
      1 n_channels = 3
      2 n_frames = meta['nframes']
----> 3 video = torch.empty(n_channels, n_frames, *meta['size'])
      4 video.shape

TypeError: empty(): argument 'size' must be tuple of ints, but found element of type float at pos 2

Do you have any suggestion to solve it? Thanks

vokhidovhusan avatar Mar 24 '21 02:03 vokhidovhusan

Ok. I found the reason. My nframes is equal to inf. I don't know why.

{'plugin': 'ffmpeg',
 'nframes': inf,
 'ffmpeg_version': '4.2.2-static https://johnvansickle.com/ffmpeg/ built with gcc 8 (Debian 8.3.0-6)',
 'codec': 'h264',
 'pix_fmt': 'yuv444p',
 'fps': 20.0,
 'source_size': (1280, 720),
 'size': (1280, 720),
 'duration': 14.0}

vokhidovhusan avatar Mar 24 '21 02:03 vokhidovhusan

Ok. I have solved it. Instead of n_frames = meta['nframes'] I checked for its type whether it is string or not. if it is string then you can do as following:

n_channels = 3
n_frames = meta['nframes'] if isinstance(meta['nframes'],str) else int(meta['duration']) * int(meta['fps'])
video = torch.empty(n_channels, n_frames, *meta['size'])
video.shape

vokhidovhusan avatar Mar 24 '21 02:03 vokhidovhusan

good job!

luyanyang98 avatar Dec 20 '22 03:12 luyanyang98