From 5eb4120209b1bf9b9b77231ad8c990c36f6fff32 Mon Sep 17 00:00:00 2001 From: bas Date: Tue, 17 Oct 2023 13:41:54 +0200 Subject: [PATCH] Add getattr for fetching library_name --- optimum/exporters/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/optimum/exporters/tasks.py b/optimum/exporters/tasks.py index 2841383eb96..4dc5ce8ae33 100644 --- a/optimum/exporters/tasks.py +++ b/optimum/exporters/tasks.py @@ -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)