Skip to content

Commit f909592

Browse files
committed
Fix model_type coercion in Engine parser
Adjust `Engine.from_model_type` to normalize non-string `model_type` values by converting either `.value` or the original object with `str(...)` in a single step. This avoids eager fallback conversion inside `getattr` and makes enum-like inputs more reliably coercible.
1 parent 42bbb1f commit f909592

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎dlclivegui/temp/engine.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ def is_tensorflow_model_dir_path(model_path: str | Path) -> bool:
2626

2727
@classmethod
2828
def from_model_type(cls, model_type: str) -> "Engine":
29+
if not isinstance(model_type, str):
30+
try:
31+
model_type = str(getattr(model_type, "value", model_type))
32+
except Exception as e:
33+
raise ValueError(f"Could not convert model_type to string: {model_type}") from e
34+
2935
if model_type.lower() == "pytorch":
3036
return cls.PYTORCH
3137
elif model_type.lower() in ("tensorflow", "base", "tensorrt", "lite"):

0 commit comments

Comments
 (0)