pykeio / ort

Fast ML inference & training for Rust with ONNX Runtime
https://ort.pyke.io/
Apache License 2.0
859 stars 100 forks source link

How to implement with YOLOX? #248

Closed hericah closed 3 months ago

hericah commented 3 months ago

Hi thanks for your work May I know how to implement with YOLOX instead of YOLOv8. I found it's slightly different between input and output, I couldn't figure out how to use data from onnx.run to create boxes.

let outputs: SessionOutputs = model.run(inputs!["images" => input.view()]?)?;
let output = outputs["output"]
     .try_extract_tensor::<f32>()?
     .t()
     .into_owned();
println!("output: {:?}", output);
output: [[[2.1308594],
  [1.5537109],
  [2.84375],
  [1.8994141],
  [1.8007813],
  ...,
  [0.88720703],
  [0.328125],
  [0.30029297],
  [-0.0110321045],
  [-0.24353027]],

 [[2.7890625],
  [3.3496094],
  [0.7338867],
  [0.6826172],
  [0.6225586],
  ...,
  [-0.6538086],
  [-0.5498047],
  [-0.7988281],
  [-0.8540039],
  [-0.33911133]],

 [[1.8193359],
  [1.8769531],
  [2.140625],
  [2.4648438],
  [2.5644531],
  ...,
  [3.0742188],
  [2.8476563],
  [2.6171875],
  [2.7265625],
  [1.8544922]],

 ...,

 [[0.00390625],
  [0.004638672],
  [0.0068359375],
  [0.0024414063],
  [0.0021972656],
  ...,
  [0.013427734],
  [0.012451172],
  [0.016113281],
  [0.0146484375],
  [0.0087890625]],

 [[0.0029296875],
  [0.0026855469],
  [0.005126953],
  [0.0026855469],
  [0.0036621094],
  ...,
  [0.0063476563],
  [0.005126953],
  [0.005859375],
  [0.0036621094],
  [0.0041503906]],

 [[0.0007324219],
  [0.00048828125],
  [0.0024414063],
  [0.0017089844],
  [0.0014648438],
  ...,
  [0.0087890625],
  [0.0068359375],
  [0.008300781],
  [0.0061035156],
  [0.005859375]]], shape=[85, 8400, 1], strides=[1, 85, 714000], layout=Ff (0xa), dynamic ndim=3