Ruff format docstring Python code (#15792)
Signed-off-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
c1882a4327
commit
d27664216b
63 changed files with 370 additions and 374 deletions
|
|
@ -32,8 +32,9 @@ class MaskDecoder(nn.Module):
|
|||
|
||||
Examples:
|
||||
>>> decoder = MaskDecoder(transformer_dim=256, transformer=transformer_module)
|
||||
>>> masks, iou_pred = decoder(image_embeddings, image_pe, sparse_prompt_embeddings,
|
||||
... dense_prompt_embeddings, multimask_output=True)
|
||||
>>> masks, iou_pred = decoder(
|
||||
... image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, multimask_output=True
|
||||
... )
|
||||
>>> print(f"Predicted masks shape: {masks.shape}, IoU predictions shape: {iou_pred.shape}")
|
||||
"""
|
||||
|
||||
|
|
@ -213,7 +214,8 @@ class SAM2MaskDecoder(nn.Module):
|
|||
>>> dense_prompt_embeddings = torch.rand(1, 256, 64, 64)
|
||||
>>> decoder = SAM2MaskDecoder(256, transformer)
|
||||
>>> masks, iou_pred, sam_tokens_out, obj_score_logits = decoder.forward(
|
||||
... image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, True, False)
|
||||
... image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, True, False
|
||||
... )
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
|
|
@ -345,7 +347,8 @@ class SAM2MaskDecoder(nn.Module):
|
|||
>>> dense_prompt_embeddings = torch.rand(1, 256, 64, 64)
|
||||
>>> decoder = SAM2MaskDecoder(256, transformer)
|
||||
>>> masks, iou_pred, sam_tokens_out, obj_score_logits = decoder.forward(
|
||||
... image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, True, False)
|
||||
... image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, True, False
|
||||
... )
|
||||
"""
|
||||
masks, iou_pred, mask_tokens_out, object_score_logits = self.predict_masks(
|
||||
image_embeddings=image_embeddings,
|
||||
|
|
|
|||
|
|
@ -417,7 +417,15 @@ class SAM2Model(torch.nn.Module):
|
|||
>>> point_inputs = {"point_coords": torch.rand(1, 2, 2), "point_labels": torch.tensor([[1, 0]])}
|
||||
>>> mask_inputs = torch.rand(1, 1, 512, 512)
|
||||
>>> results = model._forward_sam_heads(backbone_features, point_inputs, mask_inputs)
|
||||
>>> low_res_multimasks, high_res_multimasks, ious, low_res_masks, high_res_masks, obj_ptr, object_score_logits = results
|
||||
>>> (
|
||||
... low_res_multimasks,
|
||||
... high_res_multimasks,
|
||||
... ious,
|
||||
... low_res_masks,
|
||||
... high_res_masks,
|
||||
... obj_ptr,
|
||||
... object_score_logits,
|
||||
... ) = results
|
||||
"""
|
||||
B = backbone_features.size(0)
|
||||
device = backbone_features.device
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@ class BasicLayer(nn.Module):
|
|||
|
||||
Examples:
|
||||
>>> layer = BasicLayer(dim=96, input_resolution=(56, 56), depth=2, num_heads=3, window_size=7)
|
||||
>>> x = torch.randn(1, 56*56, 96)
|
||||
>>> x = torch.randn(1, 56 * 56, 96)
|
||||
>>> output = layer(x)
|
||||
>>> print(output.shape)
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ def select_closest_cond_frames(frame_idx, cond_frame_outputs, max_cond_frame_num
|
|||
|
||||
Examples:
|
||||
>>> frame_idx = 5
|
||||
>>> cond_frame_outputs = {1: 'a', 3: 'b', 7: 'c', 9: 'd'}
|
||||
>>> cond_frame_outputs = {1: "a", 3: "b", 7: "c", 9: "d"}
|
||||
>>> max_cond_frame_num = 2
|
||||
>>> selected, unselected = select_closest_cond_frames(frame_idx, cond_frame_outputs, max_cond_frame_num)
|
||||
>>> print(selected)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue