openai / glide-text2im

GLIDE: a diffusion-based text-conditional image synthesis model
MIT License
3.54k stars 500 forks source link

Fix NumPy Deprecation Warning for np.bool Usage in attention.py #50

Open conorKotwasinski opened 7 months ago

conorKotwasinski commented 7 months ago

Problem Description

The glide_text2im package currently uses np.bool in attention.py, which has been deprecated since NumPy 1.20. This results in a FutureWarning when using the package and eventually leads to an AttributeError in environments with NumPy versions that have fully removed the np.bool alias.

Proposed Solution

This pull request replaces all instances of np.bool with np.bool in the attention.py file. The np.bool data type is the recommended replacement for np.bool and is not deprecated. This change ensures compatibility with current and future versions of NumPy without altering the functionality of the glide_text2im package.

Justification

Using np.bool_ ensures that the package remains functional and free of deprecation warnings and errors with NumPy 1.20 and later. This update is necessary to maintain the package's usability in current and future Python environments, fostering a smoother user experience and compatibility with the wider Python ecosystem.

Testing

The modifications have been tested locally to verify that the FutureWarning is resolved and that the glide_text2im package functions as expected with the change. All existing tests pass, and no new functionality has been introduced, minimizing the risk of side effects.

I look forward to your feedback on this pull request. Thank you for maintaining the glide_text2im package and for considering this update to ensure its continued compatibility and performance.