Skip to content
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

Added save_dir argument to save_detector #351

Merged
merged 4 commits into from Oct 11, 2021

Conversation

ascillitoe
Copy link
Contributor

@ascillitoe ascillitoe commented Sep 28, 2021

Fix for #348.

An optional save_dir argument is used, instead of detector_name used in fetch_detector, so as to not confuse the detector_namevariable already used insave_detector. This also matches the syntax used in save_tf_model` etc.

If save_dir=None then the detector_name (from metadata) is used for save_dir instead.

@jklaise
Copy link
Member

jklaise commented Sep 28, 2021

Looking back on your comment I realize I misread it and thought your suggestion was to change the behaviour of fetch_detector. I think the behaviour of save_detector is already correct and should be kept as simple as possible without extra arguments.

@@ -470,7 +470,7 @@ def fetch_detector(filepath: Union[str, os.PathLike],
Initialised pre-trained detector.
"""
# create path (if needed)
filepath = Path(filepath).joinpath(detector_name)
filepath = Path(filepath)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jklaise perhaps this is the most straightforward fix? There is no confusing logic for the user to contend with.

We would have to modify all the notebooks though e.g. delete the filepath = os.path.join(filepath, detector_name) line in cd_distillation_cifar10.ipynb.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably what the user would expect to happen so I agree.

Wrt notebooks, should we modify the saved paths to be ./models/detector_name so the current behaviour is unchanged (i.e. running multiple notebooks saves all detectors in their own subdirectory so they can be retrieved later).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a much nicer solution with the notebooks, I'll do that 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had a go at moving the os.path.join(filepath,detector_name) outside the if load_pretrained: block, so filepath should be consistent for fetch and save routes.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

examples/ad_ae_cifar10.ipynb Outdated Show resolved Hide resolved
examples/cd_ks_cifar10.ipynb Show resolved Hide resolved
@ascillitoe
Copy link
Contributor Author

@jklaise I'm just going to check the docs examples one more time to check for any more issues like the two you found.

@ascillitoe
Copy link
Contributor Author

@jklaise I'm just going to check the docs examples one more time to check for any more issues like the two you found.

Might still have missed something, but have gone through all the notebooks with changes and didn't spot any other issues like the above.

@jklaise jklaise merged commit 92e93f0 into SeldonIO:master Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants