Unverified Commit cfc838dd authored by Denis Ismailaj's avatar Denis Ismailaj Committed by GitHub
Browse files

Respect explicitly set framework parameter in pipeline (#24322)

* Respect framework parameter

* Move check to pipeline()

* Add check inside infer_framework_load_model again
parent c5454eba
...@@ -781,19 +781,19 @@ def pipeline( ...@@ -781,19 +781,19 @@ def pipeline(
model_name = model if isinstance(model, str) else None model_name = model if isinstance(model, str) else None
# Infer the framework from the model # Load the correct model if possible
# Forced if framework already defined, inferred if it's None # Infer the framework from the model if not already defined
# Will load the correct model if possible if isinstance(model, str) or framework is None:
model_classes = {"tf": targeted_task["tf"], "pt": targeted_task["pt"]} model_classes = {"tf": targeted_task["tf"], "pt": targeted_task["pt"]}
framework, model = infer_framework_load_model( framework, model = infer_framework_load_model(
model, model,
model_classes=model_classes, model_classes=model_classes,
config=config, config=config,
framework=framework, framework=framework,
task=task, task=task,
**hub_kwargs, **hub_kwargs,
**model_kwargs, **model_kwargs,
) )
model_config = model.config model_config = model.config
hub_kwargs["_commit_hash"] = model.config._commit_hash hub_kwargs["_commit_hash"] = model.config._commit_hash
......
...@@ -277,7 +277,8 @@ def infer_framework_load_model( ...@@ -277,7 +277,8 @@ def infer_framework_load_model(
if isinstance(model, str): if isinstance(model, str):
raise ValueError(f"Could not load model {model} with any of the following classes: {class_tuple}.") raise ValueError(f"Could not load model {model} with any of the following classes: {class_tuple}.")
framework = infer_framework(model.__class__) if framework is None:
framework = infer_framework(model.__class__)
return framework, model return framework, model
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment