mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-07-11 22:29:29 +02:00
training.convert/ONNX: run strict shape inference and check model
This commit is contained in:
parent
5e531ab006
commit
1b27c7390f
2 changed files with 9 additions and 7 deletions
|
|
@ -99,7 +99,12 @@ def convert_cli(rebuild, format_, in_, out):
|
|||
model.export(out)
|
||||
elif format_ == "onnx":
|
||||
import tf2onnx
|
||||
import onnx
|
||||
tf2onnx.convert.from_keras(model, opset=18, output_path=out)
|
||||
model = onnx.load(out)
|
||||
model = onnx.shape_inference.infer_shapes(model, strict_mode=True)
|
||||
onnx.checker.check_model(model, full_check=True)
|
||||
onnx.save(model, out)
|
||||
else:
|
||||
raise ValueError("unknown output format '%s'" % format_)
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ $(MODELS_DST)/%: $(MODELS_SRC)/%
|
|||
--in $< \
|
||||
--format $(FORMAT) \
|
||||
--out $@ \
|
||||
2>&1 | tee $(notdir $<).$(FORMAT).log
|
||||
> $(notdir $<).$(FORMAT).log 2>&1 || { cat $(notdir $<).$(FORMAT).log; false; }
|
||||
|
||||
$(MODELS_DST)/%.keras: $(MODELS_SRC)/%
|
||||
eynollah-training convert \
|
||||
|
|
@ -46,7 +46,7 @@ $(MODELS_DST)/%.keras: $(MODELS_SRC)/%
|
|||
--in $< \
|
||||
--format keras \
|
||||
--out $@ \
|
||||
2>&1 | tee $(notdir $<).keras.log
|
||||
> $(notdir $<).keras.log 2>&1 || { cat $(notdir $<).keras.log; false; }
|
||||
|
||||
$(MODELS_DST)/%.h5: $(MODELS_SRC)/%
|
||||
eynollah-training convert \
|
||||
|
|
@ -54,18 +54,15 @@ $(MODELS_DST)/%.h5: $(MODELS_SRC)/%
|
|||
--in $< \
|
||||
--format hdf5 \
|
||||
--out $@ \
|
||||
2>&1 | tee $(notdir $<).hdf5.log
|
||||
> $(notdir $<).hdf5.log 2>&1 || { cat $(notdir $<).hdf5.log; false; }
|
||||
|
||||
$(MODELS_DST)/%.onnx: $(MODELS_SRC)/%
|
||||
if jq -e '.task == "segmentation" and .backbone_type == "transformer"' $</config.json &>/dev/null; then \
|
||||
echo skipping $@: vision transformer architecture currently does not work with ONNX; \
|
||||
else \
|
||||
eynollah-training convert \
|
||||
$(and $(wildcard $</config.json),--rebuild) \
|
||||
--in $< \
|
||||
--format onnx \
|
||||
--out $@ \
|
||||
2>&1 | tee $(notdir $<).onnx.log; fi
|
||||
> $(notdir $<).onnx.log 2>&1 || { cat $(notdir $<).onnx.log; false; }
|
||||
|
||||
compare:
|
||||
for i in `find $(MODELS_DST) -mindepth 2`;do \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue