Fix TFLite error and OpenVINO int8 error at imgsz=32 (#18898)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
55e422d336
commit
e99b778cc4
4 changed files with 20 additions and 5 deletions
|
|
@ -47,7 +47,7 @@ Start your compute and open a Terminal:
|
|||
### Create virtualenv
|
||||
|
||||
Create your conda virtualenv with your favorite python version and install pip in it:
|
||||
Python 3.13.1 is having some issues with some dependecies in AzureML.
|
||||
Python 3.13.1 is having some issues with some dependencies in AzureML.
|
||||
|
||||
```bash
|
||||
conda create --name yolo11env -y python=3.12
|
||||
|
|
@ -90,7 +90,7 @@ Open the compute Terminal.
|
|||
<img width="480" src="https://github.com/ultralytics/docs/releases/download/0/open-terminal.avif" alt="Open Terminal">
|
||||
</p>
|
||||
|
||||
From your compute terminal, you need to create a new ipykernel (with a specific python version - because Python 3.13.1 is having some issues with some dependecies in AzureML) that will be used by your notebook to manage your dependencies:
|
||||
From your compute terminal, you need to create a new ipykernel (with a specific python version - because Python 3.13.1 is having some issues with some dependencies in AzureML) that will be used by your notebook to manage your dependencies:
|
||||
|
||||
```bash
|
||||
conda create --name yolo11env -y python=3.12
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@
|
|||
48149018+zhixuwei@users.noreply.github.com:
|
||||
avatar: https://avatars.githubusercontent.com/u/48149018?v=4
|
||||
username: zhixuwei
|
||||
49172033+Lucashygi@users.noreply.github.com:
|
||||
avatar: https://avatars.githubusercontent.com/u/49172033?v=4
|
||||
username: Lucashygi
|
||||
49699333+dependabot[bot]@users.noreply.github.com:
|
||||
avatar: https://avatars.githubusercontent.com/u/27347476?v=4
|
||||
username: dependabot
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ def test_export_openvino_matrix(task, dynamic, int8, half, batch, nms):
|
|||
for task, dynamic, int8, half, batch, simplify, nms in product(
|
||||
TASKS, [True, False], [False], [False], [1, 2], [True, False], [True, False]
|
||||
)
|
||||
if not ((int8 and half) or (task == "classify" and nms))
|
||||
if not ((int8 and half) or (task == "classify" and nms) or (task == "obb" and nms and not TORCH_1_13))
|
||||
],
|
||||
)
|
||||
def test_export_onnx_matrix(task, dynamic, int8, half, batch, simplify, nms):
|
||||
|
|
|
|||
|
|
@ -1559,6 +1559,7 @@ class NMSModel(torch.nn.Module):
|
|||
extra_shape = pred.shape[-1] - (4 + self.model.nc) # extras from Segment, OBB, Pose
|
||||
boxes, scores, extras = pred.split([4, self.model.nc, extra_shape], dim=2)
|
||||
scores, classes = scores.max(dim=-1)
|
||||
self.args.max_det = min(pred.shape[1], self.args.max_det) # in case num_anchors < max_det
|
||||
# (N, max_det, 4 coords + 1 class score + 1 class label + extra_shape).
|
||||
out = torch.zeros(
|
||||
boxes.shape[0],
|
||||
|
|
@ -1596,14 +1597,25 @@ class NMSModel(torch.nn.Module):
|
|||
offbox = nmsbox[:, :end] + cls_offset * multiplier
|
||||
nmsbox = torch.cat((offbox, nmsbox[:, end:]), dim=-1)
|
||||
nms_fn = (
|
||||
partial(nms_rotated, use_triu=not (self.is_tf or (self.args.opset or 14) < 14)) if self.obb else nms
|
||||
partial(
|
||||
nms_rotated,
|
||||
use_triu=not (
|
||||
self.is_tf
|
||||
or (self.args.opset or 14) < 14
|
||||
or (self.args.format == "openvino" and self.args.int8) # OpenVINO int8 error with triu
|
||||
),
|
||||
)
|
||||
if self.obb
|
||||
else nms
|
||||
)
|
||||
keep = nms_fn(
|
||||
torch.cat([nmsbox, extra], dim=-1) if self.obb else nmsbox,
|
||||
score,
|
||||
self.args.iou,
|
||||
)[: self.args.max_det]
|
||||
dets = torch.cat([box[keep], score[keep].view(-1, 1), cls[keep].view(-1, 1), extra[keep]], dim=-1)
|
||||
dets = torch.cat(
|
||||
[box[keep], score[keep].view(-1, 1), cls[keep].view(-1, 1).to(out.dtype), extra[keep]], dim=-1
|
||||
)
|
||||
# Zero-pad to max_det size to avoid reshape error
|
||||
pad = (0, 0, 0, self.args.max_det - dets.shape[0])
|
||||
out[i] = torch.nn.functional.pad(dets, pad)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue