Luigi commited on
Commit
c4f84a9
·
1 Parent(s): 25f1444

Repair DEMO to run with TRT EP

Browse files
demo.sh CHANGED
@@ -1,2 +1,2 @@
1
  #!/bin/sh
2
- python3 rtmo_demo.py ./video rtmo-s.fp16.onnx
 
1
  #!/bin/sh
2
+ python3 rtmo_demo.py ./video rtmo-t.fp16.batch1.onnx
demo_batch.sh CHANGED
@@ -1,2 +1,2 @@
1
  #!/bin/sh
2
- python3 rtmo_demo_batch.py ./video rtmo-t.fp16.onnx 4
 
1
  #!/bin/sh
2
+ python3 rtmo_demo_batch.py ./video rtmo-t.fp16.batch4.onnx 4
fix_batch_dimension.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import onnx
3
+ from onnx import numpy_helper
4
+ import numpy as np
5
+
6
+ def fix_batch_dimension(input_model_path, output_model_path, batch_size=1):
7
+ # Load the input ONNX model
8
+ model = onnx.load(input_model_path)
9
+
10
+ # Iterate through the model's inputs
11
+ for input_tensor in model.graph.input:
12
+ # Get the tensor shape
13
+ tensor_shape = input_tensor.type.tensor_type.shape
14
+
15
+ # Modify the batch dimension
16
+ if len(tensor_shape.dim) > 0:
17
+ tensor_shape.dim[0].dim_value = batch_size
18
+
19
+ # Save the modified model to the output path
20
+ onnx.save(model, output_model_path)
21
+ print(f"Model saved with updated batch size of {batch_size} to {output_model_path}")
22
+
23
+ if __name__ == "__main__":
24
+ # Setup command line arguments
25
+ parser = argparse.ArgumentParser(description="Fix batch dimension of an ONNX model.")
26
+ parser.add_argument("input_model_path", type=str, help="Path to the input ONNX model.")
27
+ parser.add_argument("output_model_path", type=str, help="Path to save the output ONNX model with fixed batch dimension.")
28
+ parser.add_argument("--batch_size", type=int, default=1, help="Value of batch size to assign (default is 1).")
29
+
30
+ # Parse arguments
31
+ args = parser.parse_args()
32
+
33
+ # Call the function to fix the batch dimension
34
+ fix_batch_dimension(args.input_model_path, args.output_model_path, args.batch_size)
35
+
fix_batch_dimension_all.sh ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Loop through all .onnx files in the current directory
4
+ for model in ./*.onnx; do
5
+ # Exclude processing any files that already have a batch size in their name
6
+ if [[ ! $model =~ _batch[0-9]+\.onnx$ ]]; then
7
+ # Process for batch size 1
8
+ python fix_batch_dimension.py "$model" "${model%.onnx}_batch1.onnx" --batch_size 1
9
+ echo "Generated ${model%.onnx}_batch1.onnx"
10
+
11
+ # Process for batch size 2
12
+ python fix_batch_dimension.py "$model" "${model%.onnx}_batch2.onnx" --batch_size 2
13
+ echo "Generated ${model%.onnx}_batch2.onnx"
14
+
15
+ # Process for batch size 4
16
+ python fix_batch_dimension.py "$model" "${model%.onnx}_batch4.onnx" --batch_size 4
17
+ echo "Generated ${model%.onnx}_batch4.onnx"
18
+ fi
19
+ done
20
+
rtmo-l.fp16_batch1.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:431290c0e7a3025e08dd1fef85e41435e7fc4927195464c28aa9e7723e4db1c5
3
+ size 88036648
rtmo-l.fp16_batch2.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b765824473d07936e7346ceac100007150a722f1c1406d95077c1340b65b16d9
3
+ size 88036648
rtmo-l.fp16_batch4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:006e088660b8e6be74b6572fbcbff0723c02816252876b4546466ecca4462b9b
3
+ size 88036648
rtmo-l_batch1.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb610ad52d5090881bbb5f7b8720773846a65257ddda8f7cba29d848688d8fb6
3
+ size 175941846
rtmo-l_batch2.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cac7daf35257f78c533e088773df544806c69d03f12aef9937ecf0e161649e4a
3
+ size 175941846
rtmo-l_batch4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c83886f33bba6bda437ce9fafe2b395d33993f1bfc00a8b1f27f3a094ae69ef1
3
+ size 175941846
rtmo-m.fp16_batch1.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3ad1ffa7f34dce7df78c4b7eac88d443b36db0c1255ca19e8a5e16b24758bfbe
3
+ size 44714435
rtmo-m.fp16_batch2.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b2bd44af05d333eea99cf59a37797934e646bd3d8d146873d9a1c8b22bc7f130
3
+ size 44714435
rtmo-m.fp16_batch4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:706a49d63bc19bb45a1de326e129d8f83f24664990b544180259fadca13a73cb
3
+ size 44714435
rtmo-m_batch1.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26d4434838a4ff158f6cdcab421a08ddd82900f3fcc41ec0921d7245e2c5818d
3
+ size 89307171
rtmo-m_batch2.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f64f9494e826b39b8347af6de0e9fcb932c58762578fdcf4cdcc53be5852bacf
3
+ size 89307171
rtmo-m_batch4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a263fb2e9310073d147fe1aeac80762c4213be1bcd84be689b0973a61c36efa
3
+ size 89307171
rtmo-s.fp16_batch1.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:30f1264466acbc4782815f35f628d8d7ae845ecef95cf7281405d7a61d453dae
3
+ size 19880910
rtmo-s.fp16_batch2.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0659aacd2dcb4c3d68073e126b0af38a48d8b4952ef9a6f85f376a3c95c4a8f
3
+ size 19880910
rtmo-s.fp16_batch4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:34344796d956d2bd3e78abac5422605858a16866dae78f2e8e5fc3e9da440e8e
3
+ size 19880910
rtmo-s_batch1.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:699704b00b06b791f31d6b15a7e4bb4abd57f8dab1a60c58fc22490d4ab55c93
3
+ size 39651660
rtmo-s_batch2.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28a5f6e563ad3a20c9e2c18355514c0a2c0aa147f09017f2fbace79a9d7ba38d
3
+ size 39651660
rtmo-s_batch4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5d2304570931d9351d10f2940311f0dd8d774e92cc0ec88256d1fcfe4ee796c
3
+ size 39651660
rtmo-t.fp16_batch1.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0241fdd72ddb93b4a8aab85ca279c0e3570b5c414057ec439e2e2bc826838171
3
+ size 13742849
rtmo-t.fp16_batch2.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6cb717e8f19e544268a3ba780ae604ad1438abcb0e9fde8425b21c0faf871782
3
+ size 13742849
rtmo-t.fp16_batch4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:422e684cbd1710cd42f8bad12c243869c9fe3c998904d46a030186b6d3dbf286
3
+ size 13742849
rtmo-t_batch1.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3493fc0b00118d937db56e3aa523799441e2f1a0f40753f15c8e34f0761c3c94
3
+ size 27375829
rtmo-t_batch2.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21d77708f79cd81b644f53804f6541d672e10556d789cec8eebbeafc9d41a8ce
3
+ size 27375829
rtmo-t_batch4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5024770899ee523e13a6f683a443c4c0820f90e17cdfe3985035466a4520f772
3
+ size 27375829