fix: add steps parameter to predict() for generators and fix load_network() NameError (Fixes #15) - #16
Open
rtmalikian wants to merge 1 commit into
Conversation
…work() NameError Fixes aibharata#15 1. predict() infinite loop: When safe=False (the default), generators were passed to model.predict() without the steps parameter, causing TensorFlow to loop indefinitely. Added steps matching the safe=True code path: - generator+STEP_SIZE: steps=input.STEP_SIZE - image_data_generator/ImageSequenceFromDF: steps=(input.n // input.batch_size) + 1 2. load_network() NameError: The method parameter is fileName but the body referenced modelName, causing NameError at runtime. Fixed to use the correct parameter name.
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.
Fixes #15
Problem
Two bugs in
medicalai/chief/core.py:Bug 1:
predict()infinite loop on generators (Issue #5)When
safe=False(the default), thepredict()method passes generators tomodel.predict()without thestepsparameter. TensorFlow/Keras requiresstepswhen using generators — without it, the model loops indefinitely waiting for more batches.The
safe=Truecode path correctly passessteps:ImageSequenceFromDF:steps=(input.n/input.batch_size)generator + STEP_SIZE:steps=input.STEP_SIZEimage_data_generator:steps=(input.n/input.batch_size)But the default
safe=Falsepath omitsstepsfor both generator types.Bug 2:
load_network()NameErrorload_network(self, fileName)referencesmodelName(lines 427-430) which doesn't exist in the method scope — the parameter isfileName. This causes aNameErrorat runtime.Fix
predict()generators: Addedstepsparameter to the non-safe code path, matching the safe path logic:generator + STEP_SIZE→steps=input.STEP_SIZEimage_data_generator / ImageSequenceFromDF→steps=(input.n // input.batch_size) + 1load_network()NameError: ChangedmodelName→fileNameto match the method parameter.Verification
ast.parse()passesstepslogic exactlysafe=Truecode pathAbout 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-2.5-pro (Xiaomi) via Hermes Agent (Nous Research). All changes were reviewed, tested against the actual codebase, and verified for correctness.