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

addressing Torchscript compatibility #85

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
**This is the clone of the [TAPIR Repository](https://github.com/google-deepmind/tapnet) that addresses the Standard TAPIR model compatibility with Torchscript, see [PR#85](https://github.com/google-deepmind/tapnet/pull/85). Only _tapir_model.py,_ _nets.py_ and _utils.py_ from _torch_ directory are updated.**

**It is not yet aligned with the version 2 of the model [bootstapir_checkpoint_v2.pt](https://storage.googleapis.com/dm-tapnet/bootstap/bootstapir_checkpoint_v2.pt), only with the original version [bootstapir_checkpoint.pt](https://storage.googleapis.com/dm-tapnet/bootstap/bootstapir_checkpoint.pt).**

**Online TAPIR is not yet supported.**

---

# Tracking Any Point (TAP)

[[`TAP-Vid`](https://tapvid.github.io/)] [[`TAPIR`](https://deepmind-tapir.github.io/)] [[`RoboTAP`](https://robotap.github.io/)] [[`Blog Post`](https://deepmind-tapir.github.io/blogpost.html)] [[`BootsTAP`](https://arxiv.org/abs/2402.00847)]
Expand Down
20 changes: 16 additions & 4 deletions torch/nets.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def forward(self, x):
x = x.permute(0, 3, 1, 2)
prev_frame = torch.cat([x[0:1], x[:-1]], dim=0)
next_frame = torch.cat([x[1:], x[-1:]], dim=0)
resid = torch.cat([x, prev_frame, next_frame], axis=1)
resid = torch.cat([x, prev_frame, next_frame], dim=1)
resid = self.conv(resid)
resid = F.gelu(resid, approximate='tanh')
x += self.conv_1(resid)
Expand Down Expand Up @@ -198,10 +198,20 @@ def forward(self, x):
x = self.linear_1(x)
return x

class DummyModel:

def __init__(self):
pass

def forward(self):
return torch.tensor(0)

def __call__(self, input):
return self.forward()

class BlockV2(nn.Module):
"""ResNet V2 block."""

def __init__(
self,
channels_in: int,
Expand All @@ -223,14 +233,16 @@ def __init__(

self.use_projection = use_projection
if self.use_projection:
self.proj_conv = nn.Conv2d(
self.proj_conv = nn.Conv2d(
in_channels=channels_in,
out_channels=channels_out,
kernel_size=1,
stride=stride,
padding=0,
bias=False,
)
)
else:
self.proj_conv = DummyModel()

self.bn_0 = nn.InstanceNorm2d(
num_features=channels_in,
Expand Down
Loading