Skip to content

Conversation

@mattdangerw
Copy link
Member

The main change this allows is passing arbitrary functional models as a backbone to a task and arbitrary callables as preprocessing for a task. This should allow a lot more flexible API usage.

  • Passing Rescaling layer or a Pipeline as preprocessing for a ImageClassifier task.
  • Running augmentation on the GPU by retracing the backbone with augmentation layers included.
  • Doing more custom surgery of a backbone.

I also moved our saving routines to a PresetSaver class, but this is really just to be parallel with the PresetLoader we added for transformers/timm conversion. You can still override save_to_preset on a model if you need to. Probably more cleanups to do.

Consolidate saving into a saving class to match loading.
Plenty more cleanup to do there probably, but this will at
least bring our saving and loading routines into a common
flow.
return preprocessor


class KerasPresetSaver:
Copy link
Member Author

Choose a reason for hiding this comment

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

We might want to clean this up in the future, for now I'm just consolidating this to match the loading helper we have.

Copy link
Collaborator

@fchollet fchollet left a comment

Choose a reason for hiding this comment

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

LGTM

@mattdangerw mattdangerw force-pushed the flexible-backbone-preprocessor branch from 4abb29a to e8219e1 Compare October 2, 2024 03:32
@mattdangerw
Copy link
Member Author

Merging this! The last failure is unrelated, and has to do with image preprocessing on the torch backend and gpu <> cpu errors. I will fix up on the other PR.

@mattdangerw mattdangerw merged commit 6d80bcf into keras-team:master Oct 2, 2024
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.

2 participants