fix: replace undefined self.npy_files with correct path in assertion messages - #418
Open
rtmalikian wants to merge 1 commit into
Open
fix: replace undefined self.npy_files with correct path in assertion messages#418rtmalikian wants to merge 1 commit into
rtmalikian wants to merge 1 commit into
Conversation
…messages All 5 NpyDataset classes reference self.npy_files[index] in their assertion error messages, but npy_files is never defined as an instance attribute. This causes an AttributeError if the assertion ever triggers, masking the actual error being diagnosed. Replace with join(self.img_path, img_name) to show the full image path alongside the ground truth path, which is the intended diagnostic output. Affected files: - train_one_gpu.py - train_multi_gpus.py - extensions/point_prompt/train_point_prompt.py - extensions/text_prompt/train_text_prompt.py - comparisons/DeepLabV3+/train_deeplabv3_res50.py Fixes bowang-lab#399
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an
AttributeErrorcaused by referencing the undefined attributeself.npy_filesin assertion error messages across all 5NpyDatasetclasses in the codebase.Problem
All 5 training scripts (
train_one_gpu.py,train_multi_gpus.py,extensions/point_prompt/train_point_prompt.py,extensions/text_prompt/train_text_prompt.py,comparisons/DeepLabV3+/train_deeplabv3_res50.py) contain an assertion inNpyDataset.__getitem__()that referencesself.npy_files[index]in its error message:However, the
NpyDatasetclass never definesself.npy_files— onlyself.gt_path_files. This means:AttributeError: 'NpyDataset' object has no attribute 'npy_files'instead of showing the intended diagnostic error messageFix
Replace
self.npy_files[index]withjoin(self.img_path, img_name)to show the full image path alongside the ground truth path, which is the intended diagnostic output:Verification
ast.parse)self.npy_filesin the entire codebaseFiles Changed
train_one_gpu.pyself.npy_files[index]→join(self.img_path, img_name)train_multi_gpus.pyself.npy_files[index]→join(self.img_path, img_name)extensions/point_prompt/train_point_prompt.pyself.npy_files[index]→join(self.img_path, img_name)extensions/text_prompt/train_text_prompt.pyself.npy_files[index]→join(self.img_path, img_name)comparisons/DeepLabV3+/train_deeplabv3_res50.pyself.npy_files[index]→join(self.img_path, img_name)Fixes #399
About the Author: Raphael Malikian — Clinical AI Solutions Architect. I specialise in building and fixing AI/ML systems for healthcare, including vector databases, RAG pipelines, and clinical NLP. If you need help with your project or think I can add value to your organisation, feel free to reach out — I'd love to connect.
📧 rtmalikian@gmail.com
🔗 GitHub: https://github.com/rtmalikian
🔗 LinkedIn: http://www.linkedin.com/in/raphael-t-malikian-mbbs-bsc-hons-71075436a
Disclosure: This code was developed with assistance from mimo-v2.5-pro (Xiaomi) via Hermes Agent (Nous Research). All changes were reviewed, tested against the actual codebase, and verified for correctness.