Skip to content

Commit

Permalink
ONNX exporter library_name infer fixes (#1460)
Browse files Browse the repository at this point in the history
* Add getattr for fetching library_name

* Add raise statement to ValueError

---------

Co-authored-by: bas <[email protected]>
  • Loading branch information
baskrahmer and bk-jc authored Oct 18, 2023
1 parent 13cd58e commit 2f7d396
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,13 +1407,13 @@ def _infer_task_from_model_name_or_path(
"Cannot infer the task from a model repo with a subfolder yet, please specify the task manually."
)
model_info = huggingface_hub.model_info(model_name_or_path, revision=revision)
if model_info.library_name == "diffusers":
if getattr(model_info, "library_name", None) == "diffusers":
# TODO : getattr(model_info, "model_index") defining auto_model_class_name currently set to None
for task in ("stable-diffusion-xl", "stable-diffusion"):
if task in model_info.tags:
inferred_task_name = task
break
elif model_info.library_name == "timm":
elif getattr(model_info, "library_name", None) == "timm":
inferred_task_name = "image-classification"
else:
pipeline_tag = getattr(model_info, "pipeline_tag", None)
Expand Down Expand Up @@ -1549,7 +1549,7 @@ def infer_library_from_model(
library_name = "transformers"

if library_name is None:
ValueError(
raise ValueError(
"The library_name could not be automatically inferred. If using the command-line, please provide the argument --library (transformers,diffusers,timm)!"
)

Expand Down

0 comments on commit 2f7d396

Please sign in to comment.