Skip to content

Commit

Permalink
Reformatted code using dev/linter.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiago Crepaldi committed Jun 15, 2022
1 parent eeff5f2 commit ba9497a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion detectron2/modeling/backbone/mvit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import numpy as np
import torch
import torch.nn as nn

from fairscale.nn.checkpoint import checkpoint_wrapper
from timm.models.layers import DropPath, Mlp, trunc_normal_

Expand Down
3 changes: 1 addition & 2 deletions detectron2/modeling/backbone/swin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.checkpoint as checkpoint
from timm.models.layers import DropPath, to_2tuple, trunc_normal_

from detectron2.modeling.backbone.backbone import Backbone

from timm.models.layers import DropPath, to_2tuple, trunc_normal_


class Mlp(nn.Module):
"""Multilayer perceptron."""
Expand Down
5 changes: 2 additions & 3 deletions detectron2/modeling/backbone/vit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import fvcore.nn.weight_init as weight_init
import torch
import torch.nn as nn
from fairscale.nn.checkpoint import checkpoint_wrapper
from timm.models.layers import DropPath, Mlp, trunc_normal_

from detectron2.layers import CNNBlockBase, Conv2d, get_norm
from detectron2.modeling.backbone.fpn import _assert_strides_are_log2_contiguous

from fairscale.nn.checkpoint import checkpoint_wrapper
from timm.models.layers import DropPath, Mlp, trunc_normal_

from .backbone import Backbone
from .utils import (
PatchEmbed,
Expand Down
4 changes: 1 addition & 3 deletions projects/DensePose/densepose/modeling/cse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ def normalize_embeddings(embeddings: torch.Tensor, epsilon: float = 1e-6) -> tor
Return:
Normalized embeddings (tensor [N, D]), such that L2 vector norms are all equal to 1.
"""
return embeddings / torch.clamp(
embeddings.norm(p=None, dim=1, keepdim=True), min=epsilon
)
return embeddings / torch.clamp(embeddings.norm(p=None, dim=1, keepdim=True), min=epsilon)


def get_closest_vertices_mask_from_ES(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ def forward(
pixel_embeddings.reshape((self.embed_size, -1))[:, pixel_indices_flattened].T
)
# pixel-vertex similarity [M, K]
sim_matrix = pixel_embeddings_sampled.mm(
mesh_vertex_embeddings.T
)
sim_matrix = pixel_embeddings_sampled.mm(mesh_vertex_embeddings.T)
c_pix_vertex = F.softmax(sim_matrix / self.temperature_pix_to_vertex, dim=1)
c_vertex_pix = F.softmax(sim_matrix.T / self.temperature_vertex_to_pix, dim=1)
c_cycle = c_pix_vertex.mm(c_vertex_pix)
Expand Down

0 comments on commit ba9497a

Please sign in to comment.