Skip to content

Commit cdc9cad

Browse files
committed
Remove zoedepth non-automated zoedepth changes and zoedepth test
Signed-off-by: Phillip Kuznetsov <[email protected]>
1 parent 812e3d5 commit cdc9cad

File tree

2 files changed

+3
-33
lines changed

2 files changed

+3
-33
lines changed

src/transformers/models/zoedepth/modeling_zoedepth.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,32 +367,29 @@ def __init__(self, config):
367367
self.projection = None
368368
if config.add_projection:
369369
self.projection = nn.Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
370-
self.projection_act = nn.ReLU()
371370

372371
features = config.fusion_hidden_size
373372
self.conv1 = nn.Conv2d(features, features // 2, kernel_size=3, stride=1, padding=1)
374373
self.upsample = nn.Upsample(scale_factor=2, mode="bilinear", align_corners=True)
375374
self.conv2 = nn.Conv2d(features // 2, config.num_relative_features, kernel_size=3, stride=1, padding=1)
376-
self.conv2_act = nn.ReLU()
377375
self.conv3 = nn.Conv2d(config.num_relative_features, 1, kernel_size=1, stride=1, padding=0)
378-
self.conv3_act = nn.ReLU()
379376

380377
def forward(self, hidden_states: List[torch.Tensor]) -> torch.Tensor:
381378
# use last features
382379
hidden_states = hidden_states[self.head_in_index]
383380

384381
if self.projection is not None:
385382
hidden_states = self.projection(hidden_states)
386-
hidden_states = self.projection_act(hidden_states)
383+
hidden_states = nn.ReLU()(hidden_states)
387384

388385
hidden_states = self.conv1(hidden_states)
389386
hidden_states = self.upsample(hidden_states)
390387
hidden_states = self.conv2(hidden_states)
391-
hidden_states = self.conv2_act(hidden_states)
388+
hidden_states = nn.ReLU()(hidden_states)
392389
# we need the features here (after second conv + ReLu)
393390
features = hidden_states
394391
hidden_states = self.conv3(hidden_states)
395-
hidden_states = self.conv3_act(hidden_states)
392+
hidden_states = nn.ReLU()(hidden_states)
396393

397394
predicted_depth = hidden_states.squeeze(dim=1)
398395

tests/models/zoedepth/test_modeling_zoedepth.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
from transformers import Dinov2Config, ZoeDepthConfig
2222
from transformers.file_utils import is_torch_available, is_vision_available
23-
from transformers.pytorch_utils import is_torch_greater_or_equal_than_2_4
2423
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
2524

2625
from ...test_configuration_common import ConfigTester
@@ -355,29 +354,3 @@ def test_inference_depth_estimation_post_processing_pad_flip(self):
355354
model = ZoeDepthForDepthEstimation.from_pretrained("Intel/zoedepth-nyu-kitti").to(torch_device)
356355

357356
self.check_post_processing_test(image_processor, images, model, pad_input=True, flip_aug=True)
358-
359-
def test_export(self):
360-
self.skipTest(
361-
reason="This test fails because the beit backbone of ZoeDepth is not compatible with torch.export"
362-
)
363-
for strict in [True, False]:
364-
with self.subTest(strict=True):
365-
if not is_torch_greater_or_equal_than_2_4:
366-
self.skipTest(reason="This test requires torch >= 2.4 to run.")
367-
model = ZoeDepthForDepthEstimation.from_pretrained("Intel/zoedepth-nyu").to(torch_device).eval()
368-
image_processor = ZoeDepthImageProcessor.from_pretrained("Intel/zoedepth-nyu")
369-
image = prepare_img()
370-
inputs = image_processor(images=image, return_tensors="pt").to(torch_device)
371-
372-
exported_program = torch.export.export(
373-
model,
374-
args=(inputs["pixel_values"],),
375-
strict=strict,
376-
)
377-
with torch.no_grad():
378-
eager_outputs = model(**inputs)
379-
exported_outputs = exported_program.module().forward(inputs["pixel_values"])
380-
self.assertEqual(eager_outputs.predicted_depth.shape, exported_outputs.predicted_depth.shape)
381-
self.assertTrue(
382-
torch.allclose(eager_outputs.predicted_depth, exported_outputs.predicted_depth, atol=1e-4)
383-
)

0 commit comments

Comments
 (0)