I've encountered an issue where track_cells crashes unexpectedly with this error:
Traceback (most recent call last):
File "/train.py", line 324, in <module>
track_length=args.track_length)
File "/train.py", line 242, in evaluate
tracker.track_cells()
File "/usr/local/lib/python3.6/dist-packages/deepcell_tracking/tracking.py", line 639, in track_cells
self._track_frame(frame)
File "/usr/local/lib/python3.6/dist-packages/deepcell_tracking/tracking.py", line 623, in _track_frame
cost_matrix, predictions = self._get_cost_matrix(frame)
File "/usr/local/lib/python3.6/dist-packages/deepcell_tracking/tracking.py", line 420, in _get_cost_matrix
], axis=0)
File "<__array_function__ internals>", line 6, in stack
File "/usr/local/lib/python3.6/dist-packages/numpy/core/shape_base.py", line 423, in stack
raise ValueError('need at least one array to stack')
ValueError: need at least one array to stack
Digging into the error, I find that in _get_cost_matrix, we compare the current cell features with the future cell features, stacking together each feature into a single array. The error indicates that we are trying to stack an empty list, which means that future_feature is empty.
future_feature is initialized by _get_frame_features, which populates a dictionary with features for every cell in the frame. I think the root cause of this bug is that there are no objects in the frame, and so future_feature is returned as an empty dictionary.
It would also be prudent make sure that _fetch_tracked_features (which creates the current_feature dictionary that also gets stacked together) is also robust to empty frames.
I've encountered an issue where
track_cells
crashes unexpectedly with this error:Digging into the error, I find that in
_get_cost_matrix
, we compare the current cell features with the future cell features, stacking together each feature into a single array. The error indicates that we are trying to stack an empty list, which means thatfuture_feature
is empty.https://github.com/vanvalenlab/deepcell-tracking/blob/526b65b9aff539e340bac0aad148c762cf5eadba/deepcell_tracking/tracking.py#L414-L420
future_feature
is initialized by_get_frame_features
, which populates a dictionary with features for every cell in the frame. I think the root cause of this bug is that there are no objects in the frame, and sofuture_feature
is returned as an empty dictionary.https://github.com/vanvalenlab/deepcell-tracking/blob/526b65b9aff539e340bac0aad148c762cf5eadba/deepcell_tracking/tracking.py#L269-L273
It would also be prudent make sure that
_fetch_tracked_features
(which creates thecurrent_feature
dictionary that also gets stacked together) is also robust to empty frames.