Deeplabcut: extract_frames gets type error when trying to get more frames

Created on 8 Apr 2019  Â·  4Comments  Â·  Source: DeepLabCut/DeepLabCut

Your Operating system and DeepLabCut version
Ubuntu 16.04, anaconda env, deeplabcut 2.0.5.1

Describe the bug
When I run deeplabcut.extract_frames it asks if I want to select more frames, If I type yes I get a type error. If I just type no the function completes without issue.

To Reproduce
Steps to reproduce the behavior:

  1. Start anaconda environment, start ipython, import deeplabcut
  2. Run, deeplabcut.extract_frames(config_path)
  3. When asked to select more frames type yes

Expected behavior

No error should be returned and more frames should be selected.

Screenshots

dlc.extract_frames(config_path)
/home/tomi/anaconda3/envs/dlc2/lib/python3.6/site-packages/deeplabcut/generate_training_dataset/frame_extraction.py:100: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  cfg = yaml.load(ymlfile)
Config file read successfully.
Do you want to extract (perhaps additional) frames for video: /home/tomi/Documents/Test/02-19-19.tif ?
yes/noyes
/home/tomi/anaconda3/envs/dlc2/lib/python3.6/site-packages/deeplabcut/generate_training_dataset/frame_extraction.py:142: RuntimeWarning: invalid value encountered in log10
  indexlength = int(np.ceil(np.log10(nframes)))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-4-4dbf231eb9af> in <module>()
----> 1 dlc.extract_frames(config_path)

/home/tomi/anaconda3/envs/dlc2/lib/python3.6/site-packages/deeplabcut/generate_training_dataset/frame_extraction.py in extract_frames(config, mode, algo, crop, userfeedback, cluster_step, cluster_resizewidth, cluster_color, opencv)
    140                     duration=clip.duration
    141                     nframes=int(np.ceil(clip.duration*1./fps))
--> 142                 indexlength = int(np.ceil(np.log10(nframes)))
    143                 if crop==True:
    144                     if opencv:

ValueError: cannot convert float NaN to integer

howtousedlc

Most helpful comment

Ah, ok, I know why. All of our videos are tiff stacks, need to convert into
avi first I think.

On Mon, Apr 8, 2019, 5:23 PM Alexander Mathis notifications@github.com
wrote:

I think that might be because your video is not correctly loaded (e.g.
with fps=0 and thus NaN nframes).

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/AlexEMG/DeepLabCut/issues/261#issuecomment-481013606,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQUrz1iykVYPZTISQ5csA-me4_pxKrHMks5ve7NsgaJpZM4cjGT3
.

All 4 comments

I think that might be because your video is not correctly loaded (e.g. with fps=0 and thus NaN nframes).

Ah, ok, I know why. All of our videos are tiff stacks, need to convert into
avi first I think.

On Mon, Apr 8, 2019, 5:23 PM Alexander Mathis notifications@github.com
wrote:

I think that might be because your video is not correctly loaded (e.g.
with fps=0 and thus NaN nframes).

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/AlexEMG/DeepLabCut/issues/261#issuecomment-481013606,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQUrz1iykVYPZTISQ5csA-me4_pxKrHMks5ve7NsgaJpZM4cjGT3
.

I think it's not a video actually? /home/tomi/Documents/Test/02-19-19.tif

just an FYI though, when you get to the analysis part, there is a function such that you can avoid always converting, if you prefer tif stacks, etc!

Signature: deeplabcut.analyze_time_lapse_frames(config, directory, frametype='.png', shuffle=1, trainingsetindex=0, gputouse=None, save_as_csv=False, rgb=True)
Docstring:
Analyzed all images (of type = frametype) in a folder and stores the output in one file. 

You can crop the frames (before analysis), by changing 'cropping'=True and setting 'x1','x2','y1','y2' in the config file. 

Output: The labels are stored as MultiIndex Pandas Array, which contains the name of the network, body part name, (x, y) label position 

        in pixels, and the likelihood for each frame per body part. These arrays are stored in an efficient Hierarchical Data Format (HDF) 

        in the same directory, where the video is stored. However, if the flag save_as_csv is set to True, the data can also be exported in 

        comma-separated values format (.csv), which in turn can be imported in many programs, such as MATLAB, R, Prism, etc.

Parameters
----------
config : string
    Full path of the config.yaml file as a string.

directory: string
    Full path to directory containing the frames that shall be analyzed

frametype: string, optional
    Checks for the file extension of the frames. Only images with this extension are analyzed. The default is ``.png``

shuffle: int, optional
    An integer specifying the shuffle index of the training dataset used for training the network. The default is 1.

trainingsetindex: int, optional
    Integer specifying which TrainingsetFraction to use. By default the first (note that TrainingFraction is a list in config.yaml).

gputouse: int, optional. Natural number indicating the number of your GPU (see number in nvidia-smi). If you do not have a GPU put None.
See: https://nvidia.custhelp.com/app/answers/detail/a_id/3751/~/useful-nvidia-smi-queries

save_as_csv: bool, optional
    Saves the predictions in a .csv file. The default is ``False``; if provided it must be either ``True`` or ``False``

rbg: bool, optional.
    Whether to load image as rgb; Note e.g. some tiffs do not alow that option in io.imread, then just set this to false.

Examples
--------
If you want to analyze all frames in /analysis/project/timelapseexperiment1
>>> deeplabcut.analyze_videos('/analysis/project/reaching-task/config.yaml','/analysis/project/timelapseexperiment1')
--------

If you want to analyze all frames in /analysis/project/timelapseexperiment1
>>> deeplabcut.analyze_videos('/analysis/project/reaching-task/config.yaml','/analysis/project/timelapseexperiment1', frametype='.bmp')
--------


Was this page helpful?
0 / 5 - 0 ratings