dbolya / yolact

A simple, fully convolutional model for real-time instance segmentation.
MIT License
4.97k stars 1.32k forks source link

fix for VisibleDepritiationWarning due to numpy #838

Open FanFeast opened 7 months ago

FanFeast commented 7 months ago

Fixed Deprecation Warning for ndarray Creation from Ragged Nested Sequences

In this update, we've addressed a deprecation warning that was triggered when creating an ndarray from ragged nested sequences (i.e., a list or tuple of lists or tuples with differing lengths or shapes). The code previously allowed the creation of an array without specifying a data type, which is now deprecated behavior and can lead to unexpected results or errors in future versions.

The fix involved specifying the data type explicitly when creating the ndarray by adding dtype=object to the array creation call. This ensures that the intention is clear when ragged nested sequences are used, and it aligns the code with the updated NumPy requirements, maintaining compatibility and avoiding deprecation issues.

The specific line of code updated is in the augmentations.py file where the ndarray is created:

mode = random.choice(self.sample_options)

After the fix, this line ensures that any ndarray created from sequences of differing lengths or shapes is treated as an object array, thus conforming to the latest best practices and maintaining the stability of the codebase.