Commit aafd2ff9 authored by lucas_miranda's avatar lucas_miranda
Browse files

Propagated rule-based labels to the training set on .preprocess()

parent fd096b0e
......@@ -1092,6 +1092,11 @@ class table_dict(dict):
except ValueError:
X_train, y_train = X_train[:, :-n_annot], X_train[:, -n_annot:]
# Convert speed to a boolean value. Is the animal moving?
y_train[:, -1] = (
y_train[:, -1] > deepof.pose_utils.get_hparameters()["huddle_speed"]
)
try:
try:
X_test, y_test = X_test[:, :-n_annot], np.concatenate(
......@@ -1099,6 +1104,12 @@ class table_dict(dict):
)
except ValueError:
X_test, y_test = X_test[:, :-n_annot], X_test[:, -n_annot:]
# Convert speed to a boolean value. Is the animal moving?
y_test[:, -1] = (
y_test[:, -1] > deepof.pose_utils.get_hparameters()["huddle_speed"]
)
except IndexError:
pass
......
......@@ -559,7 +559,7 @@ def get_hparameters(hparams: dict = {}) -> dict:
"follow_frames": 10,
"follow_tol": 5,
"huddle_forward": 15,
"huddle_speed": 1,
"huddle_speed": 2,
"nose_likelihood": 0.85,
"fps": 24,
}
......@@ -782,7 +782,6 @@ def rule_based_tagging(
animal_id=_id,
)
)
tag_dict[_id + undercond + "speed"] = overall_speed(speeds, _id, undercond)
tag_dict[_id + undercond + "huddle"] = deepof.utils.smooth_boolean_array(
huddle(
coords,
......@@ -810,6 +809,9 @@ def rule_based_tagging(
animal_id=_id,
)
)
# NOTE: It's important that speeds remain the last columns.
# Preprocessing for weakly supervised autoencoders relies on this
tag_dict[_id + undercond + "speed"] = overall_speed(speeds, _id, undercond)
tag_df = pd.DataFrame(tag_dict).fillna(0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment