fix: self.clip → self.backbone in forward(), stale comment
Browse files- clip_head.py +1 -1
- gradcam.py +1 -1
clip_head.py
CHANGED
|
@@ -32,7 +32,7 @@ class CreativeScorer(nn.Module):
|
|
| 32 |
pass
|
| 33 |
else:
|
| 34 |
with torch.no_grad():
|
| 35 |
-
clip_out = self.
|
| 36 |
embedding = clip_out.pooler_output # (batch, 768)
|
| 37 |
|
| 38 |
shared = self.projection(embedding) # (batch, 256)
|
|
|
|
| 32 |
pass
|
| 33 |
else:
|
| 34 |
with torch.no_grad():
|
| 35 |
+
clip_out = self.backbone(pixel_values=pixel_values)
|
| 36 |
embedding = clip_out.pooler_output # (batch, 768)
|
| 37 |
|
| 38 |
shared = self.projection(embedding) # (batch, 256)
|
gradcam.py
CHANGED
|
@@ -41,7 +41,7 @@ def _compute_cam(
|
|
| 41 |
model.zero_grad()
|
| 42 |
|
| 43 |
# Forward outside torch.no_grad() so autograd builds the computation graph.
|
| 44 |
-
# The
|
| 45 |
# frozen while the projection layer's params remain in the graph.
|
| 46 |
outputs = model(pixel_values)
|
| 47 |
shared_repr = outputs["shared_repr"] # (1, 256)
|
|
|
|
| 41 |
model.zero_grad()
|
| 42 |
|
| 43 |
# Forward outside torch.no_grad() so autograd builds the computation graph.
|
| 44 |
+
# The backbone block inside forward() uses its own no_grad, so the backbone stays
|
| 45 |
# frozen while the projection layer's params remain in the graph.
|
| 46 |
outputs = model(pixel_values)
|
| 47 |
shared_repr = outputs["shared_repr"] # (1, 256)
|