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

Add CLIP to ivy models #34

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Add CLIP to ivy models #34

wants to merge 18 commits into from

Conversation

kgmann
Copy link

@kgmann kgmann commented Jul 6, 2023

No description provided.

@kgmann kgmann requested a review from juliagsy July 6, 2023 02:53
Copy link
Contributor

@juliagsy juliagsy left a comment

Choose a reason for hiding this comment

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

Hey Luc! Thanks for the great work so far! The comments below are mainly refactor again (and some existing conventions to follow) but please let me know if you have any question with them, thanks!

ivy_models_tests/clip/test_clip.py Outdated Show resolved Hide resolved
ivy_models_tests/clip/test_clip.py Outdated Show resolved Hide resolved
ivy_models/clip/simple_tokenizer.py Show resolved Hide resolved
ivy_models/clip/simple_tokenizer.py Outdated Show resolved Hide resolved
ivy_models/clip/simple_tokenizer.py Outdated Show resolved Hide resolved
return new_mapping


def load_clip(name: str, pretrained=True):
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be named clip_<version> to match previous conventions

ivy_models/clip/layers.py Outdated Show resolved Hide resolved
ivy_models/clip/layers.py Show resolved Hide resolved
ivy_models/clip/layers.py Show resolved Hide resolved
return image.convert("RGB")


def _transform(n_px):
Copy link
Contributor

Choose a reason for hiding this comment

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

there's an equivalent in ivy_models_tests/image_helpers.py
can we also refactor some of the helpers here to that file or folder? thanks!
ps: the image helpers were initially used during tests only, but if it is deemed better in ivy_models, please feel free to refactor this in another PR

Copy link
Author

Choose a reason for hiding this comment

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

The CLIP image transforms depend on the variant of the model that we load, so I thought it was better to handle it there for convenience. Also, as you mentioned, I think it'd be better to have some helpers to load the appropriate image preprocessing pipeline in ivy_models so that users can easily load them directly. Currently, users will have to write the appropriate image processing pipeline for each model that they load and that won't be cool for the UX.

Copy link
Contributor

Choose a reason for hiding this comment

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

we have the transform pipeline there, this function looks quite similar to that imo, the resize and centercrop args are configurable as well. do you think it can be improved with the rgb flag? Thanks!
ref: https://github.com/unifyai/models/blob/c87584bf7be32c8b2ed58e3978452645e9ff36a0/ivy_models_tests/helpers/image_helpers.py#L30

@kgmann kgmann requested review from juliagsy and removed request for juliagsy August 8, 2023 16:19
@juliagsy
Copy link
Contributor

Hey! Thanks for the changes! One quick point, I noticed the ivy.RandomNormal initialiser is throwing an error about shape` kwarg not found, tests are failing on this. Could you please double check and feel free to push a fix to ivy if needed, thanks!

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