Skip to content
11 changes: 7 additions & 4 deletions src/transformers/pipelines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
Pipeline,
PipelineDataFormat,
PipelineException,
get_default_model,
get_default_model_and_revision,
infer_framework_load_model,
)
from .conversational import Conversation, ConversationalPipeline
Expand Down Expand Up @@ -127,7 +127,7 @@
"impl": AudioClassificationPipeline,
"tf": (),
"pt": (AutoModelForAudioClassification,) if is_torch_available() else (),
"default": {"model": {"pt": "superb/wav2vec2-base-superb-ks"}},
"default": {"model": {"pt": ("superb/wav2vec2-base-superb-ks", "372e048")}},
"type": "audio",
},
"automatic-speech-recognition": {
Expand Down Expand Up @@ -528,8 +528,11 @@ def pipeline(
# Use default model/config/tokenizer for the task if no model is provided
if model is None:
# At that point framework might still be undetermined
model = get_default_model(targeted_task, framework, task_options)
logger.warning(f"No model was supplied, defaulted to {model} (https://huggingface.co/{model})")
model, default_revision = get_default_model_and_revision(targeted_task, framework, task_options)
revision = revision if revision is not None else default_revision
logger.warning(
f"No model was supplied, defaulted to {model} and revision {revision} (https://huggingface.co/{model})"
Comment thread
patrickvonplaten marked this conversation as resolved.
Outdated
)

# Retrieve use_auth_token and add it to model_kwargs to be used in .from_pretrained
model_kwargs["use_auth_token"] = model_kwargs.get("use_auth_token", use_auth_token)
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/pipelines/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def get_framework(model, revision: Optional[str] = None):
return framework


def get_default_model(targeted_task: Dict, framework: Optional[str], task_options: Optional[Any]) -> str:
def get_default_model_and_revision(targeted_task: Dict, framework: Optional[str], task_options: Optional[Any]) -> str:
Comment thread
patrickvonplaten marked this conversation as resolved.
Outdated
"""
Select a default model to use for a given task. Defaults to pytorch if ambiguous.

Expand Down