Skip to content

【开源实习】MaskFormer模型应用开发 #1864

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

Merged
merged 14 commits into from
Feb 27, 2025
Merged
1,107 changes: 1,107 additions & 0 deletions applications/Mask2Former/Inference_with_Mask2Former.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

452 changes: 452 additions & 0 deletions applications/MaskFormer/Minimal_example_of_MaskFormer_inference.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
Loading