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

feat: add longclip #20

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

feat: add longclip #20

wants to merge 3 commits into from

Conversation

bwanglzu
Copy link
Member

@bwanglzu bwanglzu commented Apr 24, 2024

support LongCLIP style training with an additional longclip arg, during training apply a non-zero PCA on image_features to obtain principal components of image_features and maintain a short_loss together with full-caption loss.

@@ -16,6 +17,7 @@
except ImportError:
hvd = None

from utils import PCA
Copy link
Collaborator

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)
Copy link
Collaborator

@koukandre koukandre Apr 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants