Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero Division error when Analyzing video #557

Closed
PerformanceGenetics opened this issue Jan 21, 2020 · 6 comments
Closed

Zero Division error when Analyzing video #557

PerformanceGenetics opened this issue Jan 21, 2020 · 6 comments
Assignees

Comments

@PerformanceGenetics
Copy link

@PerformanceGenetics PerformanceGenetics commented Jan 21, 2020

Using Google Colab.
DeepLabCut Version 2.1.5.2
Chrome

Describe the problem

run: deeplabcut.analyze_videos(path_config_file,videofile_path)

Error returned:


Using snapshot-100000 for model /content/drive/My Drive/HorseBio-BR-2020-01-15/dlc-models/iteration-0/HorseBioJan15-trainset95shuffle1
Initializing ResNet
INFO:tensorflow:Restoring parameters from /content/drive/My Drive/HorseBio-BR-2020-01-15/dlc-models/iteration-0/HorseBioJan15-trainset95shuffle1/train/snapshot-100000
INFO:tensorflow:Restoring parameters from /content/drive/My Drive/HorseBio-BR-2020-01-15/dlc-models/iteration-0/HorseBioJan15-trainset95shuffle1/train/snapshot-100000
Analyzing all the videos in the directory
Starting to analyze %  2017Affidavit.mp4
Loading  2017Affidavit.mp4
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
<ipython-input-20-131012eec99f> in <module>()
----> 1 deeplabcut.analyze_videos(path_config_file,videofile_path)

1 frames
/usr/local/lib/python3.6/dist-packages/deeplabcut/pose_estimation_tensorflow/predict_videos.py in analyze_videos(config, videos, videotype, shuffle, trainingsetindex, gputouse, save_as_csv, destfolder, batchsize, cropping, get_nframesfrommetadata, TFGPUinference, dynamic)
    214         #looping over videos
    215         for video in Videos:
--> 216             DLCscorer=AnalyzeVideo(video,DLCscorer,DLCscorerlegacy,trainFraction,cfg,dlc_cfg,sess,inputs, outputs,pdindex,save_as_csv, destfolder,TFGPUinference,dynamic)
    217 
    218         os.chdir(str(start_path))

/usr/local/lib/python3.6/dist-packages/deeplabcut/pose_estimation_tensorflow/predict_videos.py in AnalyzeVideo(video, DLCscorer, DLCscorerlegacy, trainFraction, cfg, dlc_cfg, sess, inputs, outputs, pdindex, save_as_csv, destfolder, TFGPUinference, dynamic)
    474         fps = cap.get(5) #https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get
    475         nframes = int(cap.get(7))
--> 476         duration=nframes*1./fps
    477         size=(int(cap.get(4)),int(cap.get(3)))
    478 

ZeroDivisionError: float division by zero

@MMathisLab MMathisLab changed the title Zero Division error when Analyzing video using Colab Zero Division error when Analyzing video Jan 21, 2020
@MMathisLab

This comment has been minimized.

jeylau added a commit that referenced this issue Jan 21, 2020
Preliminary check to protect users against #557.
@jeylau

This comment has been minimized.

Copy link
Collaborator

@jeylau jeylau commented Jan 22, 2020

Could you please check the value of 'videofile_path'? It looks like you passed '2017Affidavit.mp4', which is not a full video path.

@MMathisLab

This comment has been minimized.

Copy link
Collaborator

@MMathisLab MMathisLab commented Jan 29, 2020

@PerformanceGenetics - seems your path is not the full path, but we now added that it checks for a valid video. #558

@MMathisLab MMathisLab closed this Jan 29, 2020
@PerformanceGenetics

This comment has been minimized.

Copy link
Author

@PerformanceGenetics PerformanceGenetics commented Jan 30, 2020

Sorry. I was away travelling. It was the full path.....

In: path_config_file = 'C:/Users/byron/OneDrive/Documents/Biomechanics/HorseBio-BR-2020-01-15/config.yaml'
path_config_file
Out: 'C:/Users/byron/OneDrive/Documents/Biomechanics/HorseBio-BR-2020-01-15/config.yaml'

In: videofile_path = 'C:/Users/byron/OneDrive/Documents/Biomechanics/'
videofile_path
Out: "'C:/Users/byron/OneDrive/Documents/Biomechanics/'

In: import os
os.listdir('C:/Users/byron/OneDrive/Documents/Biomechanics/')
Out: ['2016GirlsRule.mp4',
'2016MaderaDancer.mp4',
'2016Summersolo.mp4',
'2017Affidavit.mp4',
'2017Aljamal.mp4',
'2017AlJamalDLC.mp4',
'2017Allezmarie.mp4',
'2017AlsDelight.mp4',
'2017Anjorie.mp4',
'2017Anyforlove.mp4']

I had it in Colab and took it out of Colab and ran it on an Anaconda env, and the same error generates now....

In: deeplabcut.analyze_videos(path_config_file,videofile_path,videotype='.mp4',save_as_csv='True',dynamic=(True,.5,10))

Using snapshot-100000 for model C:\Users\byron\OneDrive\Documents\Biomechanics\HorseBio-BR-2020-01-15\dlc-models\iteration-0\HorseBioJan15-trainset95shuffle1
Starting analysis in dynamic cropping mode with parameters: (True, 0.5, 10)
Switching batchsize to 1, num_outputs (per animal) to 1 and TFGPUinference to False (all these features are not supported in this mode).
Initializing ResNet
INFO:tensorflow:Restoring parameters from C:\Users\byron\OneDrive\Documents\Biomechanics\HorseBio-BR-2020-01-15\dlc-models\iteration-0\HorseBioJan15-trainset95shuffle1\train\snapshot-100000
INFO:tensorflow:Restoring parameters from C:\Users\byron\OneDrive\Documents\Biomechanics\HorseBio-BR-2020-01-15\dlc-models\iteration-0\HorseBioJan15-trainset95shuffle1\train\snapshot-100000
No video/s found. Please check your path!
Out: 'DLC_resnet50_HorseBioJan15shuffle1_100000'

The strange thing is that if I replace videofile_path with a direct video name like say ['C:/Users/byron/OneDrive/Documents/Biomechanics/2017AlJamal.mp4'] and leave the rest as is above, it will analyze that individual video without a problem. But if I replace videofile_path with ['C:/Users/byron/OneDrive/Documents/Biomechanics'] as per the documentation to anaylze all files in that folder, I get the float division by zero error (not the No video/s found. Please check your path! error)

@MMathisLab

This comment has been minimized.

Copy link
Collaborator

@MMathisLab MMathisLab commented Jan 30, 2020

But if I replace videofile_path with ['C:/Users/byron/OneDrive/Documents/Biomechanics'] as per the documentation to anaylze all files in that folder, I get the float division by zero error (not the No video/s found. Please check your path! error)

['C:/Users/byron/OneDrive/Documents/Biomechanics/'] <-- add the final /

@linussun

This comment has been minimized.

Copy link

@linussun linussun commented Feb 14, 2020

Also confirm that on windows local relative video paths don't work, need to provide full path.
e.g. ['G:\videofolder\blah\blah\videoname.mp4'] NOT ['.\blah\videoname.mp4']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.