mlfpm / deepof

DeepLabCut based data analysis package including pose estimation and representation learning mediated behavior recognition
MIT License
38 stars 6 forks source link

Arena detection and supervised annotation error #42

Closed maxcaa closed 5 months ago

maxcaa commented 5 months ago

Hello, I had previously used deepof and it worked quite well! However, on my new project there seems to be an issue despite not having changed the pipeline. When I create the project and mark my arenas, there is no Arena_detection file. So when I try to run the supervised model I get an error, I'm guessing it is linked to the missing Arena_detection file. Here is how I start my project:

deepof_mice = deepof.data.Project(
   project_path=".", # Path where to create project files
   video_path=PATH_VIDEOS, # Path to DLC tracked videos
   table_path=PATH_TABLES, # Path to DLC output
   project_name="deepof_mice3", # Name of the current project
   #exp_conditions={exp_ID: exp_condition} # Dictionary containing one or more experimental conditions per provided video
   bodypart_graph="deepof_14", # Labelling scheme to use. See the last tutorial for details
   arena = "polygonal-manual", # Computes arena limits, can also do it manually with polygonal-manual
   video_scale = 391
)

deepof_mice = deepof_mice.create(verbose=True) 

With the output:

Setting up project directories... Loading trajectories... Smoothing trajectories... Interpolating outliers... Iterative imputation of ocluded bodyparts... Detecting arena... Computing distances... Computing angles... invalid value encountered in arccos invalid value encountered in arccos ... invalid value encountered in arccos Computing areas... Done!

supervised = deepof_mice.supervised_annotation()

With the error:

UnpicklingError Traceback (most recent call last) Cell In[28], line 2 1 # Run the supervised model ----> 2 supervised = deepof_mice.supervised_annotation() 4 # Save the annotation results 5 #with open('supervised_annotation_result3.pkl', 'wb') as f: 6 # pickle.dump(supervised, f)

File c:\Users\maxca\anaconda3\envs\deepof\lib\site-packages\deepof\data.py:1631, in Coordinates.supervised_annotation(self, params, center, align, video_output, frame_limit, debug, n_jobs, propagate_labels) 1628 tag_index = raw_coords[key].index 1629 self._trained_model_path = resource_filename(name, "trained_models") -> 1631 supervised_tags = deepof.annotation_utils.supervised_tagging( 1632 self, 1633 raw_coords=raw_coords, 1634 coords=coords, 1635 dists=dists, 1636 full_features=features_dict, 1637 speeds=speeds, 1638 video=get_close_matches( 1639 key, 1640 [vid for vid in self._videos if vid.startswith(key)], 1641 cutoff=0.1, 1642 n=1, 1643 )[0], 1644 trained_model_path=self._trained_model_path, 1645 center=center, 1646 params=params, 1647 ) 1649 supervised_tags.index = tag_index 1650 tag_dict[key] = supervised_tags

File c:\Users\maxca\anaconda3\envs\deepof\lib\site-packages\deepof\annotation_utils.py:566, in supervised_tagging(coord_object, raw_coords, coords, dists, speeds, full_features, video, trained_model_path, center, params) 556 # Load pre-trained models for ML annotated traits 558 with open( 559 os.path.join( 560 trained_model_path, (...) 564 "rb", 565 ) as est: --> 566 huddle_estimator = pickle.load(est) 568 # Extract useful information from coordinates object 569 tracks = list(coord_object._tables.keys())

UnpicklingError: invalid load key, 'v'.

Thank you for this project,

Max

maxcaa commented 5 months ago

It appears the issue comes from trying to unpickle the 'deepof_supervised_huddle_estimator.pkl' file, it returns the error I posted above.

I tried unpickling it myself and got the same error, I've tried deleting the environment and redownloading to no success and also tried on another computer.

JulianAlvarezdeGiorgi commented 5 months ago

I solved it by downloading the .pkl file alone from the github repository (https://github.com/mlfpm/deepof/tree/master/deepof/trained_models/deepof_supervised), and replacing it. Normally it is located in “...\anaconda3\envs\deepof\Lib\site-packages\deepof\trained_models\deepof_supervised”.

lucasmiranda42 commented 5 months ago

Dear all,

apologies for the trouble. We released a patch yesterday (v0.6.2) that takes care of this issue. Normal installation should work again, without any copying from the repository.

Best, and thank you for using DeepOF! Lucas