Skip to content

Commit

Permalink
Add short form parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
PINTO0309 committed Sep 9, 2022
1 parent 3d2100b commit dfc6351
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ $ pip install -U onnx \
https://github.com/PINTO0309/simple-onnx-processing-tools#docker

## 2. CLI Usage
```bash
```
$ scc4onnx -h
usage:
scc4onnx [-h]
--input_onnx_file_path INPUT_ONNX_FILE_PATH
--output_onnx_file_path OUTPUT_ONNX_FILE_PATH
[--input_op_names_and_order_dims INPUT_OP_NAME ORDER_DIM]
[--channel_change_inputs INPUT_OP_NAME DIM]
[--non_verbose]
-if INPUT_ONNX_FILE_PATH
-of OUTPUT_ONNX_FILE_PATH
[-ioo INPUT_OP_NAME ORDER_DIM]
[-cci INPUT_OP_NAME DIM]
[-n]
optional arguments:
-h, --help
show this help message and exit
--input_onnx_file_path INPUT_ONNX_FILE_PATH
-if INPUT_ONNX_FILE_PATH, --input_onnx_file_path INPUT_ONNX_FILE_PATH
Input onnx file path.
--output_onnx_file_path OUTPUT_ONNX_FILE_PATH
-of OUTPUT_ONNX_FILE_PATH, --output_onnx_file_path OUTPUT_ONNX_FILE_PATH
Output onnx file path.
--input_op_names_and_order_dims INPUT_OP_NAME ORDER_DIM
-ioo INPUT_OP_NAMES_AND_ORDER_DIMS INPUT_OP_NAMES_AND_ORDER_DIMS, --input_op_names_and_order_dims INPUT_OP_NAMES_AND_ORDER_DIMS INPUT_OP_NAMES_AND_ORDER_DIMS
Specify the name of the input_op to be dimensionally changed and the order of the
dimensions after the change.
The name of the input_op to be dimensionally changed can be specified multiple times.
Expand All @@ -64,7 +64,7 @@ optional arguments:
--input_op_names_and_order_dims bbb [0,2,3,1] \
--input_op_names_and_order_dims ccc [0,3,1,2,4,5]
--channel_change_inputs INPUT_OP_NAME DIM
-cci CHANNEL_CHANGE_INPUTS CHANNEL_CHANGE_INPUTS, --channel_change_inputs CHANNEL_CHANGE_INPUTS CHANNEL_CHANGE_INPUTS
Change the channel order of RGB and BGR.
If the original model is RGB, it is transposed to BGR.
If the original model is BGR, it is transposed to RGB.
Expand All @@ -83,7 +83,7 @@ optional arguments:
--channel_change_inputs bbb 1 \
--channel_change_inputs ccc 5
--non_verbose
-n, --non_verbose
Do not show all information logs. Only error logs are displayed.
```

Expand All @@ -108,29 +108,29 @@ order_conversion(
input_onnx_file_path: Optional[str]
Input onnx file path.
Either input_onnx_file_path or onnx_graph must be specified.

output_onnx_file_path: Optional[str]
Output onnx file path.
If output_onnx_file_path is not specified, no .onnx file is output.

onnx_graph: Optional[onnx.ModelProto]
onnx.ModelProto.
Either input_onnx_file_path or onnx_graph must be specified.
onnx_graph If specified, ignore input_onnx_file_path and process onnx_graph.

input_op_names_and_order_dims: Optional[dict]
Specify the name of the input_op to be dimensionally changed and
the order of the dimensions after the change.
The name of the input_op to be dimensionally changed
can be specified multiple times.

e.g.
input_op_names_and_order_dims = {
"input_op_name1": [0,3,1,2],
"input_op_name2": [0,2,3,1],
"input_op_name3": [0,3,1,2,4,5],
}

channel_change_inputs: Optional[dict]
Change the channel order of RGB and BGR.
If the original model is RGB, it is transposed to BGR.
Expand All @@ -144,18 +144,18 @@ order_conversion(
dimension_number_representing_the_channel must specify
the dimension position after the change in input_op_names_and_order_dims.
For example, dimension_number_representing_the_channel is 1 for NCHW and 3 for NHWC.

e.g.
channel_change_inputs = {
"aaa": 1,
"bbb": 3,
"ccc": 2,
}

non_verbose: Optional[bool]
Do not show all information logs. Only error logs are displayed.
Default: False

Returns
-------
order_converted_graph: onnx.ModelProto
Expand Down
2 changes: 1 addition & 1 deletion scc4onnx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from scc4onnx.onnx_input_order_converter import order_conversion, main

__version__ = '1.0.4'
__version__ = '1.0.5'
5 changes: 5 additions & 0 deletions scc4onnx/onnx_input_order_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,21 @@ def order_conversion(
def main():
parser = ArgumentParser()
parser.add_argument(
'-if',
'--input_onnx_file_path',
type=str,
required=True,
help='Input onnx file path.'
)
parser.add_argument(
'-of',
'--output_onnx_file_path',
type=str,
required=True,
help='Output onnx file path.'
)
parser.add_argument(
'-ioo',
'--input_op_names_and_order_dims',
nargs=2,
action='append',
Expand All @@ -453,6 +456,7 @@ def main():
'--input_op_names_and_order_dims ccc [0,3,1,2,4,5]'
)
parser.add_argument(
'-cci',
'--channel_change_inputs',
nargs=2,
action='append',
Expand All @@ -475,6 +479,7 @@ def main():
'--channel_change_inputs ccc 5'
)
parser.add_argument(
'-n',
'--non_verbose',
action='store_true',
help='Do not show all information logs. Only error logs are displayed.'
Expand Down

0 comments on commit dfc6351

Please sign in to comment.