Problems with label_frames()

deeplabcut

#1

Hello everyone,

I have a problem using the label_frames() command in Windows. It seems as if deeplabcut is not able to load the frames it itself extracted from the video with lable_extract(). To explain myself better, let me walk you through my code:

  1. Create a new project using:
config_path=deeplabcut.create_new_project('DeepLab0','Trial_1',['C:\\Users\\reyre\\Desktop\\MasterProject\\InitialVideos\\Video1.avi'],working_directory='C:\\Users\\reyre\\Desktop\\MasterProject')
  1. extract frames as:
deeplabcut.extract_frames(config_path,'automatic','uniform')
  1. With the config.yaml file succesfully generated, I extract the frames as:
deeplabcut.label_frames(config_path)
  1. The frames are extracted and stored in the labeled-data folder (The video is about 20s and I am extracting 100 frames). And here is where my issue begins. Because I can clearly see the .png frames in the folder. However, when I execute deeplabcut.label_frames(config_path) and use the GUI to load the frames, the labeled-data folder looks empty. And if I just select the folder and click on load, I get the errors shown at the bottom.
    Do you have any clue of why I cannot visualize the frames and load them into the GUI?

I will appreciate any piece of advice you could provide me.

Thank you very much.

TypeError                                 Traceback (most recent call last)
C:\Users\reyre\Desktop\MasterProject\DeepLabCut-master\DeepLabCut-master\deeplabcut\utils\auxiliaryfunctions.py in read_config(configname)
     73     try:
---> 74         with open(path, 'r') as f:
     75             cfg = ruamelFile.load(f)

TypeError: invalid file: WindowsPath('C:/Users/reyre/Desktop/MasterProject/DeepLab0-Trial_1-2019-02-06/config.yaml')

During handling of the above exception, another exception occurred:

IndexError                                Traceback (most recent call last)
C:\Users\reyre\Desktop\MasterProject\DeepLabCut-master\DeepLabCut-master\deeplabcut\generate_training_dataset\labeling_toolbox.py in browseDir(self, event)
    369
    370 # Reading config file and its variables
--> 371         self.cfg = auxiliaryfunctions.read_config(self.config_file)
    372         self.scorer = self.cfg['scorer']
    373         self.bodyparts = self.cfg['bodyparts']

C:\Users\reyre\Desktop\MasterProject\DeepLabCut-master\DeepLabCut-master\deeplabcut\utils\auxiliaryfunctions.py in read_config(configname)
     75             cfg = ruamelFile.load(f)
     76     except Exception as err:
---> 77         if err.args[2] == "could not determine a constructor for the tag '!!python/tuple'":
     78             with open(path, 'r') as ymlfile:
     79                 print("Converting to novel config.yaml format!")

IndexError: tuple index out of range

I even tried loading the labeled-data from the example folder Reaching-MacKenzie-2018-08-30, but I get the exact same problem.

Please help


#2

you’ll need to update your DLC package; seems you have created the project with 2.0.3 or lower, but are now using 2.0.4, please do pip install deeplabcut==2.0.4.1 - or in the config yaml file just delete the '!!python/tuple' then you’ll be all set!


#3

Hi MWMathis,
Thank you very much for your response.
I tried pip-installing deeplabcut as you said, but it said all the requirements were already satisfied for that version… anyway, I uninstalled my deeplabcut and typed pip install deeplabcut==2.0.4.1.
However, I am still having the same problem, and my config.yaml file doesn’t have any ‘!!python/tuple’…

Do you have any other idea?


#4

Can you tell me what you edited in the config file (or post it here)? perhaps there is a clue…


#5

When I posted the error, I changed the start, stop and frames2pick. However, I have done many attempts even with the default configuration and it is still unable to detect the frames.

Here is the current confi.yaml

# Project definitions (do not edit)
Task: DeepLab0
scorer: Trial_1
date: Feb6

# Project path (change when moving around)
project_path: C:\Users\reyre\Desktop\MasterProject\DeepLab0-Trial_1-2019-02-06

# Annotation data set configuration (and individual video cropping parameters)
video_sets:
  C:\Users\reyre\Desktop\MasterProject\InitialVideos\monkey1.avi:
    crop: 0, 968, 0, 400
bodyparts:
- Hand
- Finger1
- Finger2
- Joystick
start: 0.5
stop: 0.7
numframes2pick: 100

# Plotting configuration
pcutoff: 0.1
dotsize: 12
alphavalue: 0.7
colormap: hsv

# Training,Evaluation and Analysis configuration
TrainingFraction:
- 0.95
iteration: 0
resnet: 50
snapshotindex: -1
batch_size: 4

# Cropping Parameters (for analysis and outlier frame detection)
cropping: false
#if cropping is true for analysis, then set the values here:
x1: 0
x2: 640
y1: 277
y2: 624

# Refinement configuration (parameters from annotation dataset configuration also relevant in this stage)
corner2move2:
- 50
- 50
move2corner: true


#6

could you re-set the config_path variable to config_path = 'C:\\Users\\reyre\\Desktop\\MasterProject\\DeepLab0-Trial_1-2019-02-06\\config.yaml' and try again?


#7

Still not working… Any more ideas?


#8

it seems you are not using the site-packges version of DLC, i.e. the pip install, since you must be working inside the downloaded DLC folder (i.e. I can see that from here: C:\Users\reyre\Desktop\MasterProject\DeepLabCut-master\DeepLabCut-master\deeplabcut\generate_training_dataset\labeling_toolbox.py in browseDir(self, event) )

Would you double check you are indeed using the latest pip installed version by not working inside the downloaded folder, i.e in terminal work from the folder your project is in. C:/Users/reyre/Desktop/MasterProject/

to check the version you are using, please test deeplabcut.__version__ and the location deeplabcut.__file__ for example, i’m using the pip version, so it looks like this:

In [1]: import deeplabcut

In [2]: deeplabcut.__file__
Out[2]: '/home/mackenzie/anaconda3/envs/DLC2/lib/python3.6/site-packages/deeplabcut/__init__.py'

In [3]: deeplabcut.__version__
Out[3]: '2.0.4.1'


#9

I uninstalled DLC, deleted the DeepLabCut-master folder and pip-installed DLC2.0.4.1 once more. I double checked the version and location as you said, but the same problem remains…

(dlc-windowsGPU) C:\>ipython
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 16:05:27) [MSC v.1900 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import deeplabcut

In [2]: deeplabcut.__file__
Out[2]: 'c:\\users\\reyre\\anaconda3\\envs\\dlc-windowsgpu\\lib\\site-packages\\deeplabcut\\__init__.py'

In [3]: deeplabcut.__version__
Out[3]: '2.0.4.1'

Below are the thrown errors when I load the empty folder (which has the .png frameS) with the label_frames GUI:

In [4]: deeplabcut.label_frames(config_path)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
c:\users\reyre\anaconda3\envs\dlc-windowsgpu\lib\site-packages\deeplabcut\utils\auxiliaryfunctions.py in read_config(configname)
     73     try:
---> 74         with open(path, 'r') as f:
     75             cfg = ruamelFile.load(f)

TypeError: invalid file: WindowsPath('C:/Users/reyre/Desktop/MasterProject/DeepLab0-Trial_1-2019-02-06/config.yaml')

During handling of the above exception, another exception occurred:

IndexError                                Traceback (most recent call last)
c:\users\reyre\anaconda3\envs\dlc-windowsgpu\lib\site-packages\deeplabcut\generate_training_dataset\labeling_toolbox.py in browseDir(self, event)
    369
    370 # Reading config file and its variables
--> 371         self.cfg = auxiliaryfunctions.read_config(self.config_file)
    372         self.scorer = self.cfg['scorer']
    373         self.bodyparts = self.cfg['bodyparts']

c:\users\reyre\anaconda3\envs\dlc-windowsgpu\lib\site-packages\deeplabcut\utils\auxiliaryfunctions.py in read_config(configname)
     75             cfg = ruamelFile.load(f)
     76     except Exception as err:
---> 77         if err.args[2] == "could not determine a constructor for the tag '!!python/tuple'":
     78             with open(path, 'r') as ymlfile:
     79                 print("Converting to novel config.yaml format!")

IndexError: tuple index out of range

What else you think it could be?

Thank you very much for helping me.


#10

It seems like the slashes of the WindowsPath in the invalid file thrown TypeError are inverted….
You think it may be a clue?
Although I find it very strange, since the config_path is set correctly and it works fine with .extract_labels. (Plus I double checked by setting the path again with both ‘C:\’ and r’C:’

TypeError: invalid file: WindowsPath('C:/Users/reyre/Desktop/MasterProject/DeepLab0-Trial_1-2019-02-06/config.yaml')


#11

I’m not sure. are you sure you are using the anaconda file we supply, as it seems you are using Python 3.5, and I remember in the past this was an issue, hence why we say 3.6 and it’s in the conda file. Could you re-build the env and just double check? we are thinking about how it could be that it wrote the path incorrectly. It does not do this on our windows machine with 3.6

dependencies:
  - python=3.6
  - tensorflow-gpu==1.12
  - cudnn=7
  - wxpython
  - jupyter
  - pytables==3.4.3 #problem with 3.4.4
  - pip:
    - deeplabcut

#12

Hi MWMathis,
It is working now, thank you very much. Python version was the problem indeed.

The first time I installed it, I downloaded the Deeplabcut-Master folder from the website and set the environment using the contained dlc-windowsGPU as:

conda env create -f dlc-windowsGPU.yaml

(Maybe the file was not updated with the correct path?)

This time I created with the ‘alternative form’, using:

conda create -n <nameyourenvironment> python=3.6

After re-installing everything, it was finally able to open the frames for the labelling.

Thank you very much for your help.


#13

Then if you don’t use the supplied conda file, be sure you conda install pytables==3.4.3; there are permission issues for Windows users otherwise that you will hit later in the process…