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.
|
# Convert from dict to arrays |
|
current_feature_arr = np.stack([ |
|
current_feature[k] for k in current_feature |
|
], axis=1) # time axis already included |
|
future_feature_arr = np.stack([ |
|
future_feature[k] for k in future_feature |
|
], axis=0) |
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.
|
frame_features = {} |
|
for cell_id in cells_in_frame: |
|
f = self._get_feature(frame, cell_id, feature_name=feature_name) |
|
frame_features[cell_id] = f |
|
return frame_features |
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_cellscrashes 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_featureis empty.deepcell-tracking/deepcell_tracking/tracking.py
Lines 414 to 420 in 526b65b
future_featureis 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_featureis returned as an empty dictionary.deepcell-tracking/deepcell_tracking/tracking.py
Lines 269 to 273 in 526b65b
It would also be prudent make sure that
_fetch_tracked_features(which creates thecurrent_featuredictionary that also gets stacked together) is also robust to empty frames.