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

Enabled typing check for densenet #3395

Open
wants to merge 8 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
4 changes: 0 additions & 4 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ ignore_errors = True

ignore_errors = True

[mypy-torchvision.models.densenet.*]

ignore_errors=True

[mypy-torchvision.models.detection.anchor_utils]

ignore_errors = True
Expand Down
6 changes: 3 additions & 3 deletions torchvision/models/densenet.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
from collections import OrderedDict
from functools import partial
from typing import Any, List, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple, cast

import torch
import torch.nn as nn
Expand Down Expand Up @@ -116,7 +116,7 @@ def __init__(
)
self.add_module("denselayer%d" % (i + 1), layer)

def forward(self, init_features: Tensor) -> Tensor:
def forward(self, init_features: Tensor) -> Tensor: # type: ignore[override]
features = [init_features]
for name, layer in self.items():
new_features = layer(features)
Expand Down Expand Up @@ -227,7 +227,7 @@ def _load_state_dict(model: nn.Module, weights: WeightsEnum, progress: bool) ->
r"^(.*denselayer\d+\.(?:norm|relu|conv))\.((?:[12])\.(?:weight|bias|running_mean|running_var))$"
)

state_dict = weights.get_state_dict(progress=progress, check_hash=True)
state_dict = cast(Dict[str, Tensor], weights.get_state_dict(progress=progress, check_hash=True))
for key in list(state_dict.keys()):
res = pattern.match(key)
if res:
Expand Down