Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ONNX exporter library_name infer fixes #1460

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions optimum/exporters/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1391,13 +1391,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 @@ -1533,7 +1533,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
Loading