Skip to content

Commit

Permalink
default clip_loss to 0 when finetuning
Browse files Browse the repository at this point in the history
  • Loading branch information
moro-no-kimi authored and rwightman committed May 15, 2023
1 parent a09d519 commit fb72f4d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/open_clip/loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ def __init__(
self.caption_loss = nn.CrossEntropyLoss(ignore_index=pad_id)

def forward(self, image_features, text_features, logits, labels, logit_scale, output_dict=False):
clip_loss = super().forward(image_features, text_features, logit_scale)
clip_loss = self.clip_loss_weight * clip_loss

clip_loss = 0

if self.clip_loss_weight:
clip_loss = super().forward(image_features, text_features, logit_scale)
clip_loss = self.clip_loss_weight * clip_loss

caption_loss = self.caption_loss(
logits.permute(0, 2, 1),
Expand Down

0 comments on commit fb72f4d

Please sign in to comment.