Skip to content

Commit

Permalink
Fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
SatyaJandhyalaAtMS committed Feb 27, 2023
1 parent 4d8743f commit 8310f60
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/transformers/models/swinv2/modeling_swinv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,10 @@ def forward(self, pixel_values: Optional[torch.FloatTensor]) -> Tuple[torch.Tens
pixel_values = self.maybe_pad(pixel_values, height, width)
embeddings = self.projection(pixel_values)
_, _, height, width = embeddings.shape
output_dimensions = (height.item() if torch.is_tensor(height) else height,
width.item() if torch.is_tensor(width) else width)
output_dimensions = (
height.item() if torch.is_tensor(height) else height,
width.item() if torch.is_tensor(width) else width,
)
embeddings = embeddings.flatten(2).transpose(1, 2)

return embeddings, output_dimensions
Expand Down Expand Up @@ -1167,7 +1169,7 @@ def forward(
>>> image_processor = AutoImageProcessor.from_pretrained("microsoft/swinv2-tiny-patch4-window8-256")
>>> model = Swinv2ForMaskedImageModeling.from_pretrained("microsoft/swinv2-tiny-patch4-window8-256")
>>> num_patches = (model.config.image_size // model.config.patch_size) ** 2
>>> num_patches = (model.config.image_size // model.config.patch_size)**2
>>> pixel_values = image_processor(images=image, return_tensors="pt").pixel_values
>>> # create random boolean mask of shape (batch_size, num_patches)
>>> bool_masked_pos = torch.randint(low=0, high=2, size=(1, num_patches)).bool()
Expand Down

0 comments on commit 8310f60

Please sign in to comment.