Skip to content

Commit fb72f4d

Browse files
moro-no-kimirwightman
authored andcommitted
default clip_loss to 0 when finetuning
1 parent a09d519 commit fb72f4d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/open_clip/loss.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,12 @@ def __init__(
158158
self.caption_loss = nn.CrossEntropyLoss(ignore_index=pad_id)
159159

160160
def forward(self, image_features, text_features, logits, labels, logit_scale, output_dict=False):
161-
clip_loss = super().forward(image_features, text_features, logit_scale)
162-
clip_loss = self.clip_loss_weight * clip_loss
161+
162+
clip_loss = 0
163+
164+
if self.clip_loss_weight:
165+
clip_loss = super().forward(image_features, text_features, logit_scale)
166+
clip_loss = self.clip_loss_weight * clip_loss
163167

164168
caption_loss = self.caption_loss(
165169
logits.permute(0, 2, 1),

0 commit comments

Comments
 (0)