-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Adapt "Natural language image search with a Dual Encoder" Demo to Keras 3 and Keras Hub #2209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @vinayak19th, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly updates the 'Natural language image search with a Dual Encoder' demo to align with Keras 3, introducing multi-backend support for training with both TensorFlow and Torch. The changes focus on modernizing the underlying libraries, improving model architecture with a more advanced vision encoder, and optimizing the data processing pipeline for better performance and clarity. The overall goal is to provide a robust and up-to-date example for natural language image search within the Keras ecosystem. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Removed accidental extra Adam Optimizer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully updates the "Natural language image search with a Dual Encoder" demo to Keras 3, including migrating from TensorFlow Hub to Keras Hub and adding multi-backend support. The changes are well-structured, with notable improvements like upgrading the vision encoder to EfficientNetV2 and moving text preprocessing into the tf.data pipeline for better performance. My feedback includes a critical suggestion to reintroduce shuffling in the data pipeline to ensure proper model training, along with several medium-severity recommendations to improve code clarity and maintainability by removing commented-out code, unused variables, and replacing hardcoded values with defined constants.
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This is a great pull request that successfully updates the example to Keras 3 and Keras Hub, enabling multi-backend support and using modern components. The code is much clearer and follows current best practices. I've found a critical syntax error in a print statement that needs to be fixed. I also have some high-severity feedback regarding the dataset download and extraction logic, specifically about cleaning up large temporary files and ensuring path consistency. Additionally, I've included a few medium-severity suggestions to improve robustness and add support for the JAX backend to make it fully Keras 3 compatible. Overall, excellent work on this migration!
| if keras.config.backend() == "torch": | ||
| self.train_step = self.train_step_torch | ||
| elif keras.config.backend() == "tensorflow": | ||
| self.train_step = self.train_step_tf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to implement in Jax fully yet
Summary
This PR updates the 'Natural language image search with a Dual Encoder' example to Keras 3 with Torch and Tensorflow Backend support for training, however, still using tf.data for dataloading and pre-processing.
Changelog
Major Changes:
tf.xfunctions to Keras 3ops.xsupporting full multi-backend functionalitytrain_stepimplementations for the Tensorflow and Torch backends in the Dual Encoder with automatic selection of the correct implementation based on the backend.wgetpackage.Minor Changes: