- Notifications
You must be signed in to change notification settings - Fork 244
[Benchmark] Add RefCOCO #1109
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
[Benchmark] Add RefCOCO #1109
Conversation
Summary of ChangesHello @mushenL, 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 integrates the RefCOCO benchmark into the 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. 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.
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 adds a new benchmark for RefCOCO. The changes include an evaluation library for calculating scores and a data adapter for processing the dataset. My review focuses on improving code robustness, correctness, and maintainability. I've suggested handling potential division-by-zero errors, using proper exception handling, replacing string-based exceptions with actual exception objects, and improving code clarity by using _ for unused variables and translating comments to English. I also recommend re-enabling a commented-out try-except block to prevent crashes during metric calculation.
| segmentation = record.get('segmentation') | ||
| image_data = refcoco_seg_doc_to_visual(image_data, segmentation) | ||
| else: | ||
| raise 'Invalid eval mode parameter' |
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.
Raising a string literal like 'Invalid eval mode parameter' will result in a TypeError at runtime, not the exception you might expect. You should raise an actual Exception instance, such as ValueError.
| raise 'Invalid eval mode parameter' | |
| raise ValueError('Invalid eval mode parameter') |
| elif self.eval_mode in ['bbox', 'seg']: | ||
| target = record.get('answer') | ||
| else: | ||
| raise 'Invalid eval mode parameter' |
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.
Raising a string literal like 'Invalid eval mode parameter' will result in a TypeError at runtime, not the exception you might expect. You should raise an actual Exception instance, such as ValueError.
| raise 'Invalid eval mode parameter' | |
| raise ValueError('Invalid eval mode parameter') |
| # try: | ||
| results = process_results(doc, filtered_prediction) | ||
| score.value.update(results) | ||
| | ||
| score.main_score_name = doc['eval_mode'] | ||
| | ||
| # except Exception as e: | ||
| # logger.error(f'Error calculating ref_coco metrics: {e}') | ||
| # score.value = {} |
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.
The try...except block is commented out. This is risky as any error during metric calculation in process_results will crash the evaluation for this sample. It's better to enable this error handling to gracefully manage failures and log them, allowing the evaluation to continue with other samples.
| # try: | |
| results = process_results(doc, filtered_prediction) | |
| score.value.update(results) | |
| score.main_score_name = doc['eval_mode'] | |
| # except Exception as e: | |
| # logger.error(f'Error calculating ref_coco metrics: {e}') | |
| # score.value = {} | |
| try: | |
| results = process_results(doc, filtered_prediction) | |
| score.value.update(results) | |
| score.main_score_name = doc['eval_mode'] | |
| except Exception as e: | |
| logger.error(f'Error calculating ref_coco metrics: {e}') | |
| score.value = {} |
| | ||
| def extract_answer(self, prediction: str, task_state: TaskState): | ||
| if task_state.metadata['eval_mode'] == 'bbox_rec': | ||
| # 匹配[a, b, c, d]格式的答案 |
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.
add refcoco benchmark