Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 6, 2024
1 parent 82e3240 commit 22bb115
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions kornia/models/detector/rtdetr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Optional

import torch
import torch.nn as nn
from torch import nn

from kornia.contrib.models.rt_detr import DETRPostProcessor
from kornia.contrib.models.rt_detr.model import RTDETR, RTDETRConfig
Expand Down Expand Up @@ -66,7 +66,7 @@ def build(
return ObjectDetector(
model,
ResizePreProcessor(image_size) if image_size is not None else nn.Identity(),
DETRPostProcessor(confidence_threshold)
DETRPostProcessor(confidence_threshold),
)

@staticmethod
Expand Down Expand Up @@ -119,24 +119,21 @@ def to_onnx(

if image_size is None:
val_image = rand(1, 3, 640, 640)
dynamic_axes={
'input' : {0 : 'batch_size', 2: 'height', 3: 'width'},
'output' : {0 : 'batch_size', 2: 'height', 3: 'width'}
dynamic_axes = {
"input": {0: "batch_size", 2: "height", 3: "width"},
"output": {0: "batch_size", 2: "height", 3: "width"},
}
else:
val_image = rand(1, 3, image_size, image_size)
dynamic_axes={
'input' : {0 : 'batch_size'},
'output' : {0 : 'batch_size'}
}
dynamic_axes = {"input": {0: "batch_size"}, "output": {0: "batch_size"}}
torch.onnx.export(
detector,
val_image,
onnx_name,
export_params=True,
opset_version=17,
do_constant_folding=True,
input_names=['input'],
output_names=['output'],
dynamic_axes=dynamic_axes
input_names=["input"],
output_names=["output"],
dynamic_axes=dynamic_axes,
)

0 comments on commit 22bb115

Please sign in to comment.