Triangulate 3d, KeyError: 'TraningFraction'

Hi,
I was able to create a calibration for 2 cameras and when I ran deeplabcut.triangulate(config_path3d, video_folder, save_as_csv=True), it identifies my video pairs but gives an error:

List of pairs: [[’/Users/ravindra/desktop/Freeflight_data_Indianus/bright/ind-2-camera-L.avi’, ‘/Users/ravindra/desktop/Freeflight_data_Indianus/bright/ind-2-camera-R.avi’]]
Analyzing video /Users/ravindra/desktop/Freeflight_data_Indianus/bright/ind-2-camera-L.avi using config_file_camera-L
Traceback (most recent call last):
File “”, line 1, in
File “/Users/ravindra/anaconda3/envs/dlc-macOS-CPU/lib/python3.6/site-packages/deeplabcut/pose_estimation_3d/triangulation.py”, line 119, in triangulate
trainFraction = cfg[‘TrainingFraction’][trainingsetindex]
File “/Users/ravindra/anaconda3/envs/dlc-macOS-CPU/lib/python3.6/site-packages/ruamel/yaml/comments.py”, line 691, in getitem
return ordereddict.getitem(self, key)

KeyError: ‘TrainingFraction’

Does anyone know how to resolve this?

Thanks
Ravi

what version of DLC are you using?
Are you sure the shuffle is correct, etc in the 3d config.yaml fle?

Thank you so much for pointing out the error.
I had made a mistake in the config file for the camera L and R. It should be the master config file used for training 2d videos. Also, I changed the iteration and shuffle in the config files and was able to run the triangulate function.

But after I triangulated and when I ran create labelled 3d videos, I get the following error.

deeplabcut.create_labeled_video_3d(config_path,[’/Users/ravindra/desktop/Freeflight_data_Indianus/bright’],draw_skeleton=False)
Traceback (most recent call last):
File “”, line 1, in
File “/Users/ravindra/anaconda3/envs/dlc-macOS-CPU/lib/python3.6/site-packages/deeplabcut/pose_estimation_3d/plotting3D.py”, line 101, in create_labeled_video_3d
cam_names = cfg_3d[“camera_names”]
File “/Users/ravindra/anaconda3/envs/dlc-macOS-CPU/lib/python3.6/site-packages/ruamel/yaml/comments.py”, line 691, in getitem
return ordereddict.getitem(self, key)
KeyError: ‘camera_names’

Now the config_path there is the config file of master folder with 2d training videos right?
It is as follows:

and the 3d config file is as follows:

I do not understand what is wrong with the camera names there.
The videos were labeled properly and could get the .h5 files

Have I made a mistake?

I am using Version 2.2b7.

Cheers

Hey @ravi, make sure you pass the 3d config file; it is the only one with the key “camera_names”. :slight_smile:

1 Like

Hi @jeylau
I think for the labelling we provide the path to .h5 file which I presume has the 3d co-ordinates.

If I change the config_path to config_path3d, then I get an error:

So I think the master 2d file config_path should be passed here.
deeplabcut.create_labeled_video_3d(config_path,[’/Users/ravindra/desktop/Freeflight_data_Indianus/bright’],draw_skeleton=False)

If you have tried this, let me know what you added for the config_path in the above command.
Thanks

Hi @ravi - the issue is the path to the triangulation file is not passed correctly. For each function in ipython you can type : deeplabcut.create_labeled_video_3d? i.e add the ? and you get the info about what to pass, i.e. you need to pass (1) 3d config.yaml file, (2) the triangulated file folder (3) the video folder… (4) draw_skeleton=True

create_labeled_video_3d(config, path, videofolder=None, start=0, end=None, trailpoints=0, videotype='avi', view=[-113, -270], xlim=[None, None], ylim=[None, None], zlim=[None, None], draw_skeleton=True)
        Creates a video with views from the two cameras and the 3d reconstruction for a selected number of frames.
    
        Parameters
        ----------
        config : string
            Full path of the config.yaml file as a string.
    
        path : list
            A list of strings containing the full paths to triangulated files for analysis or a path to the directory, where all the triangulated files are stored.
    
        videofolder: string
            Full path of the folder where the videos are stored. Use this if the vidoes are stored in a different location other than where the triangulation files are stored. By default is ``None`` and therefore looks for video files in the directory where the triangulation file is stored.
    
        start: int
            Integer specifying the start of frame index to select. Default is set to 0.
    
        end: int
            Integer specifying the end of frame index to select. Default is set to None, where all the frames of the video are used for creating the labeled video.
    
        trailpoints: int
            Number of revious frames whose body parts are plotted in a frame (for displaying history). Default is set to 0.
    
        videotype: string, optional
            Checks for the extension of the video in case the input is a directory.
    Only videos with this extension are analyzed. The default is ``.avi``
    
        view: list
            A list that sets the elevation angle in z plane and azimuthal angle in x,y plane of 3d view. Useful for rotating the axis for 3d view
    
        xlim: list
            A list of integers specifying the limits for xaxis of 3d view. By default it is set to [None,None], where the x limit is set by taking the minimum and maximum value of the x coordinates for all the bodyparts.
   

also, @jeylau is correct, it must be the 3d config file :wink: he’s a core-developer of DLC :wink:

My ignorance on full display there! My apologies @jeylau
Thanks @MWMathis.

The folder with videos also has all the triangulated files (.h5 and pickle files).

So I ran the 3d config file and the triangulated folder but got an error as I mentioned earlier.
deeplabcut.create_labeled_video_3d(config_path3d,[’/Users/ravindra/Desktop/Freeflight_data_Indianus/bright/’],draw_skeleton=False)


What does this Keyerror: 3d
and unknown projection ‘3d’ mean?

My .h5 file has z values in it.

Thanks

No worries. The skeleton needs to be set to true.

I tried that as well, but it gives the same error. My triangulation path is correct right?

If that is the folder with Ravi-freeflight.h5, yes

Oh I see your error. Your Skeleton is incorrect!

Do you only have 1 point? This won’t work for plotting in our code then; you need to drop - - bodypart1 from skeleton in config files and replace with [ ]

Yes. Its a fly and I only have one point. I was able to plot using this same code in February (of course different version).
I will try that. If it does not work, I will use the x,y,z co-ordinate csv file to plot them in python.
Thanks for your help.