mirror of
https://github.com/THU-MIG/yolov10.git
synced 2025-05-29 18:44:22 +08:00
Add OBB save_txt
feature (#7450)
This commit is contained in:
parent
b54055a2c7
commit
e795277391
@ -285,7 +285,8 @@ class Results(SimpleClass):
|
|||||||
txt_file (str): txt file path.
|
txt_file (str): txt file path.
|
||||||
save_conf (bool): save confidence score or not.
|
save_conf (bool): save confidence score or not.
|
||||||
"""
|
"""
|
||||||
boxes = self.boxes
|
is_obb = self.obb is not None
|
||||||
|
boxes = self.obb if is_obb else self.boxes
|
||||||
masks = self.masks
|
masks = self.masks
|
||||||
probs = self.probs
|
probs = self.probs
|
||||||
kpts = self.keypoints
|
kpts = self.keypoints
|
||||||
@ -297,7 +298,7 @@ class Results(SimpleClass):
|
|||||||
# Detect/segment/pose
|
# Detect/segment/pose
|
||||||
for j, d in enumerate(boxes):
|
for j, d in enumerate(boxes):
|
||||||
c, conf, id = int(d.cls), float(d.conf), None if d.id is None else int(d.id.item())
|
c, conf, id = int(d.cls), float(d.conf), None if d.id is None else int(d.id.item())
|
||||||
line = (c, *d.xywhn.view(-1))
|
line = (c, *(d.xyxyxyxyn.view(-1) if is_obb else d.xywhn.view(-1)))
|
||||||
if masks:
|
if masks:
|
||||||
seg = masks[j].xyn[0].copy().reshape(-1) # reversed mask.xyn, (n,2) to (n*2)
|
seg = masks[j].xyn[0].copy().reshape(-1) # reversed mask.xyn, (n,2) to (n*2)
|
||||||
line = (c, *seg)
|
line = (c, *seg)
|
||||||
@ -640,6 +641,15 @@ class OBB(BaseTensor):
|
|||||||
"""Return the boxes in xyxyxyxy format, (N, 4, 2)."""
|
"""Return the boxes in xyxyxyxy format, (N, 4, 2)."""
|
||||||
return ops.xywhr2xyxyxyxy(self.xywhr)
|
return ops.xywhr2xyxyxyxy(self.xywhr)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@lru_cache(maxsize=2)
|
||||||
|
def xyxyxyxyn(self):
|
||||||
|
"""Return the boxes in xyxyxyxy format, (N, 4, 2)."""
|
||||||
|
xyxyxyxyn = self.xyxyxyxy.clone() if isinstance(self.xyxyxyxy, torch.Tensor) else np.copy(self.xyxyxyxy)
|
||||||
|
xyxyxyxyn[..., 0] /= self.orig_shape[1]
|
||||||
|
xyxyxyxyn[..., 1] /= self.orig_shape[1]
|
||||||
|
return xyxyxyxyn
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@lru_cache(maxsize=2)
|
@lru_cache(maxsize=2)
|
||||||
def xyxy(self):
|
def xyxy(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user