feat: migration of natural language image search with a dual encoder to keras 3#2288
feat: migration of natural language image search with a dual encoder to keras 3#2288maitry63 wants to merge 11 commits intokeras-team:masterfrom
Conversation
Summary of ChangesHello @maitry63, 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 modernizes the Natural Language Image Search tutorial by migrating its entire codebase from Keras 2 to Keras 3. The core objective was to achieve full backend-agnosticism, allowing the model to run seamlessly on various deep learning backends like JAX, PyTorch, and TensorFlow. This involved significant updates to data handling, model architecture definitions, and the training loop, ensuring compatibility with the latest Keras API and leveraging Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
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
|
There was a problem hiding this comment.
Code Review
This pull request successfully migrates the Natural Language Image Search example to Keras 3, making it backend-agnostic and updating it to use modern Keras APIs like keras.ops and keras_nlp. A critical security issue was identified regarding the use of insecure HTTP connections for downloading the MS-COCO dataset; updating these URLs to HTTPS is recommended to protect against potential Man-in-the-Middle attacks during data preparation. Additionally, a few suggestions have been provided to address potential issues, such as a missing hyperparameter in the optimizer and a change in the data processing logic that could impact performance.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request successfully migrates the Natural Language Image Search example to Keras 3, making it backend-agnostic. The changes are extensive and well-executed, including updating the data pipeline from TFRecords to PyDataset, replacing TensorFlow-specific APIs with keras.ops and keras_nlp, and refactoring the DualEncoder model to use the modern Keras 3 compute_loss override. I have a couple of suggestions to improve code clarity and fix a potential bug in the projection head implementation and remove some redundant code in the matching function.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request successfully migrates the Natural Language Image Search example to Keras 3, leveraging modern features like keras.utils.PyDataset, keras.ops, and keras_nlp for a backend-agnostic implementation. The refactoring also improves the model's architecture and aligns with current best practices. However, a critical security vulnerability has been introduced by globally bypassing SSL certificate verification (ssl._create_unverified_context). This exposes the application to Man-in-the-Middle attacks, especially during data and model downloads. Addressing this security flaw is paramount. Additionally, a couple of minor suggestions are provided for further code enhancement.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request successfully migrates the Dual Encoder image search tutorial to Keras 3, making it backend-agnostic and leveraging KerasNLP for the text encoder. However, a critical security issue was identified where SSL certificate verification is explicitly disabled during data download, which could expose users to Man-in-the-Middle attacks. Additionally, there's a significant change in the architecture of the projection head that likely deviates from the original intent, and some performance redundancies exist in the loss computation and inference steps.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request successfully migrates the Natural Language Image Search example to Keras 3, making it backend-agnostic and updating it to use modern Keras APIs like keras.utils.PyDataset and keras_nlp. However, a critical security vulnerability was identified in the data download logic where SSL certificate verification is explicitly disabled, exposing it to Man-in-the-Middle attacks. This issue must be addressed to ensure secure data downloads.
sachinprasadhs
left a comment
There was a problem hiding this comment.
I have added my comments, please address, for the resolved Gemini comments, please mark them as resolved.
This PR migrates the Natural language image search with a Dual Encoder tutorial from Keras 2 to Keras 3. The implementation is now fully backend-agnostic, allowing it to run seamlessly on JAX, PyTorch, and TensorFlow.
Colab file - Notebook