-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: add longclip #20
base: main
Are you sure you want to change the base?
Conversation
src/open_clip/loss.py
Outdated
@@ -16,6 +17,7 @@ | |||
except ImportError: | |||
hvd = None | |||
|
|||
from utils import PCA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from .utils import PCA
@@ -200,6 +205,9 @@ def train_one_epoch( | |||
|
|||
losses['embedding_loss'] = args.emb_loss_weight * embedding_loss | |||
|
|||
if args.longclip: | |||
modelout_short = model(images_short, texts_short) | |||
loss_short = loss(**modelout_short, output_dict=True, pca_dim=32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
losses['short_loss'] = loss(**modelout_short, output_dict=True, pca_dim=32)
this also, if we use only one loss for image-text pair
support LongCLIP style training with an additional
longclip
arg, during training apply a non-zero PCA onimage_features
to obtain principal components ofimage_features
and maintain ashort_loss
together with full-caption loss.