Skip to content

Commit 4b6aa66

Browse files
authored
Merge pull request #792 from PINTO0309/fix/auto-json
`--auto_generate_json_on_error`
2 parents 2bff6c8 + cdc32af commit 4b6aa66

File tree

5 files changed

+100
-280
lines changed

5 files changed

+100
-280
lines changed

AUTO_JSON_FEATURE_SUMMARY.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ onnx2tf -i model.onnx -prf saved_model/model_auto.json
144144

145145
### 3. Command Line Integration
146146
- Added `-agj, --auto_generate_json` option
147+
- Added `-agje, --auto_generate_json_on_error` option (opt-in, disabled by default)
147148
- Removed mutual exclusivity with `-cotof`
148149
- Automatic JSON usage when both options are specified
149150

@@ -158,4 +159,4 @@ For a 6D tensor, there are 720 possible permutations to test. The tool will syst
158159

159160
## Summary
160161

161-
This implementation enables onnx2tf to automatically propose solutions for conversion errors and accuracy issues. Users no longer need to manually create JSON files - the tool automatically discovers optimal conversion parameters through systematic exploration of the parameter space. The feature represents a significant improvement in usability, especially for complex models with non-standard dimension arrangements.
162+
This implementation enables onnx2tf to automatically propose solutions for conversion errors and accuracy issues. Users no longer need to manually create JSON files - the tool automatically discovers optimal conversion parameters through systematic exploration of the parameter space. The feature represents a significant improvement in usability, especially for complex models with non-standard dimension arrangements. To avoid surprising users with new files, automatic generation on accuracy errors is now opt-in via `--auto_generate_json_on_error`.

CLAUDE.md

Lines changed: 0 additions & 216 deletions
This file was deleted.

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ Video speed is adjusted approximately 50 times slower than actual speed.
309309
docker run --rm -it \
310310
-v `pwd`:/workdir \
311311
-w /workdir \
312-
ghcr.io/pinto0309/onnx2tf:1.28.2
312+
ghcr.io/pinto0309/onnx2tf:1.28.3
313313

314314
or
315315

316316
# Authentication is not required for pulls from Docker Hub.
317317
docker run --rm -it \
318318
-v `pwd`:/workdir \
319319
-w /workdir \
320-
docker.io/pinto0309/onnx2tf:1.28.2
320+
docker.io/pinto0309/onnx2tf:1.28.3
321321

322322
or
323323

@@ -476,7 +476,7 @@ onnx2tf -i resnet18-v1-7.onnx -otfv1pb
476476
# Automatic JSON generation only
477477
# Generates an optimal parameter replacement JSON file for model conversion.
478478
# The JSON file is saved to {model_name}_auto.json when conversion errors occur
479-
# or accuracy issues are detected.
479+
# or accuracy issues are detected and the feature is explicitly enabled.
480480
onnx2tf -i model.onnx -agj
481481

482482
# Accuracy validation only (no JSON generation)
@@ -489,6 +489,11 @@ onnx2tf -i model.onnx -cotof
489489
# to validate the model accuracy. This ensures the best possible conversion accuracy.
490490
onnx2tf -i model.onnx -agj -cotof
491491

492+
# Accuracy validation with opt-in JSON generation on error
493+
# Generates a parameter replacement JSON only when accuracy errors greater than 1e-2
494+
# are detected during validation.
495+
onnx2tf -i model.onnx -cotof -agje
496+
492497
# INT8 Quantization, Full INT8 Quantization
493498
# INT8 Quantization with INT16 activation, Full INT8 Quantization with INT16 activation
494499
# Dynamic Range Quantization
@@ -2026,6 +2031,11 @@ optional arguments:
20262031
WARNING: This option performs an exhaustive search to find the optimal conversion patterns,
20272032
which can take a very long time depending on the model complexity.
20282033
2034+
-agje, --auto_generate_json_on_error
2035+
Attempts to generate a parameter replacement JSON when accuracy validation finds errors
2036+
greater than 1e-2. Useful for quickly capturing fixes during -cotof runs.
2037+
Disabled by default to avoid unexpected file generation.
2038+
20292039
-dms, --disable_model_save
20302040
Does not save the converted model. For CIs RAM savings.
20312041
@@ -2096,6 +2106,7 @@ convert(
20962106
mvn_epsilon: Union[float, NoneType] = 0.0000000001,
20972107
param_replacement_file: Optional[str] = '',
20982108
auto_generate_json: Optional[bool] = False,
2109+
auto_generate_json_on_error: Optional[bool] = False,
20992110
check_gpu_delegate_compatibility: Optional[bool] = False,
21002111
check_onnx_tf_outputs_elementwise_close: Optional[bool] = False,
21012112
check_onnx_tf_outputs_elementwise_close_full: Optional[bool] = False,
@@ -2449,6 +2460,11 @@ convert(
24492460
the generated JSON is used to re-evaluate accuracy.
24502461
Default: False
24512462

2463+
auto_generate_json_on_error: Optional[bool]
2464+
When accuracy validation detects errors greater than 1e-2, attempts to generate
2465+
a parameter replacement JSON as a best-effort fix.
2466+
Default: False
2467+
24522468
check_gpu_delegate_compatibility: Optional[bool]
24532469
Run TFLite ModelAnalyzer on the generated Float16 tflite model
24542470
to check if the model can be supported by GPU Delegate.

onnx2tf/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from onnx2tf.onnx2tf import convert, main
22

3-
__version__ = '1.28.2'
3+
__version__ = '1.28.3'

0 commit comments

Comments
 (0)