Skip to content

add setter for dtype #257

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

Closed
wants to merge 1 commit into from
Closed

add setter for dtype #257

wants to merge 1 commit into from

Conversation

kaiyuyue
Copy link

Sometimes, we would like to just use the text encoder by removing the visual model, e.g.,

model, _ = clip.load("ViT-B/32")
del model.visual  # keep the text encoder only
text_features = model.encode_text(text_tokens)

This will throw an error that CLIP has no attribute self.dtype because the dtype attr depends on the visual model part. Also, we cannot directly assign a new dtype to it because it is decorated by the @property.

So this PR aims to solve the above issue. With this PR, we can do

model.dtype = ${new dtype} 

by adding a property setter for the attribute of dtype.

@kaiyuyue kaiyuyue closed this Aug 11, 2022
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.

1 participant