Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,696 changes: 910 additions & 786 deletions application/backend/uv.lock

Large diffs are not rendered by default.

410 changes: 260 additions & 150 deletions application/ui/src-tauri/Cargo.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ def _predict_by_feat_single(
results.scores = torch.cat(mlvl_scores)
results.labels = torch.cat(mlvl_labels)
if with_score_factors:
# pyrefly: ignore[no-matching-overload]
# If with_score_factors is True, mlvl_score_factors is always a list of Tensor
results.score_factors = torch.cat(mlvl_score_factors)

return self._bbox_post_process(results=results, cfg=cfg, rescale=rescale, with_nms=with_nms, img_meta=img_meta)
Expand Down Expand Up @@ -544,11 +546,13 @@ def export_by_feat(

batch_mlvl_bboxes_pred = torch.cat(mlvl_valid_bboxes, dim=1)
batch_scores = torch.cat(mlvl_valid_scores, dim=1)
batch_priors = torch.cat(mlvl_valid_priors, dim=1)
batch_priors = torch.cat(mlvl_valid_priors, dim=1) # pyrefly: ignore[no-matching-overload]

batch_bboxes = self.bbox_coder.decode_export(batch_priors, batch_mlvl_bboxes_pred, max_shape=img_shape)

if with_score_factors:
# pyrefly: ignore[no-matching-overload]
# If with_score_factors is True, mlvl_score_factors is always a list of Tensor
batch_score_factors = torch.cat(mlvl_score_factors, dim=1)

if not self.use_sigmoid_cls:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,8 @@ def _get_decoder_input(

if denoising_bbox_unact is not None:
enc_topk_bbox_unact = torch.concat([denoising_bbox_unact, enc_topk_bbox_unact], dim=1)
content = torch.concat([denoising_logits, content], dim=1)
if denoising_logits is not None:
content = torch.concat([denoising_logits, content], dim=1)

return content, enc_topk_bbox_unact, enc_topk_bboxes_list, enc_topk_logits_list, enc_outputs_logits

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,8 @@ def _get_decoder_input(

if denoising_bbox_unact is not None:
enc_topk_bbox_unact = torch.concat([denoising_bbox_unact, enc_topk_bbox_unact], dim=1)
content = torch.concat([denoising_logits, content], dim=1)
if denoising_logits is not None:
content = torch.concat([denoising_logits, content], dim=1)

return content, enc_topk_bbox_unact, enc_topk_bboxes_list, enc_topk_logits_list, enc_outputs_logits

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
Reference : https://github.com/WongKinYiu/YOLO
"""

from __future__ import annotations

import torch
from torch import Tensor, nn

Expand All @@ -24,7 +26,7 @@ def __init__(self, dim: int = 1) -> None:
super().__init__()
self.dim = dim

def forward(self, x: Tensor) -> Tensor:
def forward(self, x: list[Tensor]) -> Tensor:
"""Forward function."""
return torch.cat(x, self.dim)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def export_by_feat(
# loop over features, decode boxes
mlvl_valid_bboxes = []
mlvl_scores = []
mlvl_valid_anchors = []
mlvl_valid_anchors: list[Tensor] = []
for cls_score, bbox_pred, anchors in zip(
mlvl_cls_scores,
mlvl_bbox_preds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _forward_feature(self, inputs: Tensor) -> Tensor:
x = self._transform_inputs(inputs)
feats = self.convs(x)
if self.concat_input:
feats = self.conv_cat(torch.cat([x, feats], dim=1))
feats = self.conv_cat(torch.cat([x, feats], dim=1)) # pyrefly: ignore[no-matching-overload]
return feats

def forward(self, inputs: Tensor) -> Tensor:
Expand Down
18 changes: 7 additions & 11 deletions library/src/getitune/data/utils/structures/mask/mask_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

from typing import TYPE_CHECKING

import numpy as np
import pycocotools.mask as mask_utils
import torch
from torchvision.ops import roi_align

if TYPE_CHECKING:
import numpy as np
from torchvision import tv_tensors


Expand Down Expand Up @@ -106,19 +106,15 @@ def crop_and_resize_masks(
if len(annos) == 0:
return torch.empty((0, *out_shape), dtype=torch.float, device=device)

# convert bboxes to tensor
if isinstance(bboxes, np.ndarray):
bboxes = torch.from_numpy(bboxes).to(device=device)
if isinstance(inds, np.ndarray):
inds = torch.from_numpy(inds).to(device=device)
bboxes_tensor = torch.from_numpy(bboxes).to(device=device)
inds_tensor = torch.from_numpy(inds).to(device=device)

num_bbox = bboxes.shape[0]
# pyrefly: ignore[no-matching-overload]
fake_inds = torch.arange(num_bbox, device=device).to(dtype=bboxes.dtype)[:, None]
rois = torch.cat([fake_inds, bboxes], dim=1) # Nx5
num_bbox = bboxes_tensor.shape[0]
fake_inds = torch.arange(num_bbox, device=device).to(dtype=bboxes_tensor.dtype)[:, None]
rois = torch.cat([fake_inds, bboxes_tensor], dim=1) # Nx5
rois = rois.to(device=device)
if num_bbox > 0:
gt_masks_th = annos.index_select(0, inds).to(dtype=rois.dtype)
gt_masks_th = annos.index_select(0, inds_tensor).to(dtype=rois.dtype)
targets = roi_align(gt_masks_th[:, None, :, :], rois, out_shape, 1.0, 0, True).squeeze(1)
resized_masks = targets >= 0.5
else:
Expand Down
Loading
Loading