Skip to content

Comments

fix: remove TensorFlow dependency from image processing#577

Open
Sheshank-singh wants to merge 1 commit intogoogle-deepmind:mainfrom
Sheshank-singh:fix/remove-tensorflow-dependency
Open

fix: remove TensorFlow dependency from image processing#577
Sheshank-singh wants to merge 1 commit intogoogle-deepmind:mainfrom
Sheshank-singh:fix/remove-tensorflow-dependency

Conversation

@Sheshank-singh
Copy link

Replace TensorFlow's JPEG encode/decode operations with pure JAX/PIL implementation. This change:

  • Removes unnecessary TensorFlow dependency from gemma/multimodal/image.py
  • Improves consistency by using only JAX/NumPy for ML operations
  • Uses PIL (already imported) for JPEG encoding/decoding instead
  • Maintains identical functionality and behavior

Implementation details:

  • Clips image to uint8 range (0-255) for JPEG compatibility
  • Uses PIL to encode image to JPEG bytes buffer
  • Decodes JPEG bytes back to RGB array for standardization
  • Converts back to float32 JAX array for subsequent processing

This closes the TODO comment that requested TensorFlow dependency removal. The PIL library is part of Python standard ecosystem and already used elsewhere in the file for image loading.

Files Modified:

  • gemma/multimodal/image.py

Replace TensorFlow's JPEG encode/decode operations with pure JAX/PIL
implementation. This change:

- Removes unnecessary TensorFlow dependency from gemma/multimodal/image.py
- Improves consistency by using only JAX/NumPy for ML operations
- Uses PIL (already imported) for JPEG encoding/decoding instead
- Maintains identical functionality and behavior

Implementation details:
- Clips image to uint8 range (0-255) for JPEG compatibility
- Uses PIL to encode image to JPEG bytes buffer
- Decodes JPEG bytes back to RGB array for standardization
- Converts back to float32 JAX array for subsequent processing

This closes the TODO comment that requested TensorFlow dependency removal.
The PIL library is part of Python standard ecosystem and already used
elsewhere in the file for image loading.

Files Modified:
- gemma/multimodal/image.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant