Skip to content

Commit

Permalink
【开源实习】Mask2Former模型应用开发 (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
linrx-ctrl authored Feb 27, 2025
1 parent 8c26b18 commit 1bd7e81
Show file tree
Hide file tree
Showing 3 changed files with 1,109 additions and 3 deletions.
1,107 changes: 1,107 additions & 0 deletions applications/Mask2Former/Inference_with_Mask2Former.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@

if is_mindspore_available():
import mindspore
from mindspore import nn


# Copied from transformers.models.detr.image_processing_detr.max_across_indices
Expand Down Expand Up @@ -215,7 +214,7 @@ def compute_segments(
segments: List[Dict] = []

if target_size is not None:
mask_probs = nn.functional.interpolate(
mask_probs = ops.interpolate(
mask_probs.unsqueeze(0), size=target_size, mode="bilinear", align_corners=False
)[0]

Expand Down Expand Up @@ -1103,7 +1102,7 @@ def post_process_instance_segmentation(
mask_cls = class_queries_logits[i]

scores = ops.softmax(mask_cls, axis=-1)[:, :-1]
labels = ops.arange(num_classes).unsqueeze(0).repeat(num_queries, 1).flatten()
labels = ops.arange(num_classes).unsqueeze(0).tile((num_queries, 1)).flatten()

scores_per_image, topk_indices = scores.flatten().topk(num_queries, sorted=False)
labels_per_image = labels[topk_indices]
Expand Down

0 comments on commit 1bd7e81

Please sign in to comment.