KumarLabJax / JABS-behavior-classifier

Behavior Classifier Component from the Jax Animal Behavior System
Other
11 stars 1 forks source link

classifly.py doesn't store extended features when using train #21

Closed SkepticRaven closed 1 month ago

SkepticRaven commented 1 year ago

When using the classify.py trained classifier, it does not properly save/load optional features.

Error Log:

> python3 /behavior-classifier/classify.py train training_control/grooming_training_20230703_130257.h5 training_control/grooming_control_250.pickle
Training classifier for: grooming
  Classifier Type: XGBoost
  Window Size: 60
  Social: False
  Distance Unit: CM
Saving trained classifier to 'training_control/grooming_control_250.pickle'
> python3 /behavior-classifier/classify.py classify --classifier training_control/grooming_control_250.pickle --input-pose 2002_pose_est_v5.h5 --out-dir test
Classifying using trained classifier: training_control/grooming_control_250.pickle
  Classifier type: XGBoost
  Behavior: grooming
  Window Size: 60
  Social: False
  Distance Unit: CM
Traceback (most recent call last):
  File "/behavior-classifier/classify.py", line 346, in <module>
    main()
  File "/behavior-classifier/classify.py", line 205, in main
    classify_main()
  File "/behavior-classifier/classify.py", line 309, in classify_main
    classify_pose(classifier, in_pose_path, out_dir, behavior, window_size,
  File "/behavior-classifier/classify.py", line 79, in classify_pose
    for group, features in required_features.items():
AttributeError: 'NoneType' object has no attribute 'items'

Printing the features yields that they should be {'landmark': ['distance_to_corner', 'bearing_to_corner']}, which exist in the original h5 file used for training. Without the check that it's failing on (eg if None was passed forward), then the default would attempt to include features that didn't exist in these files (lixit/food). This error occurs with single mouse in a pose_v5 file format (single mouse open field data with arena corners).