(mapping, pipeline_class_name, throw_error_if_not_exist: bool = True)
| 213 | |
| 214 | |
| 215 | def _get_task_class(mapping, pipeline_class_name, throw_error_if_not_exist: bool = True): |
| 216 | def get_model(pipeline_class_name): |
| 217 | for task_mapping in SUPPORTED_TASKS_MAPPINGS: |
| 218 | for model_name, pipeline in task_mapping.items(): |
| 219 | if pipeline.__name__ == pipeline_class_name: |
| 220 | return model_name |
| 221 | |
| 222 | model_name = get_model(pipeline_class_name) |
| 223 | |
| 224 | if model_name is not None: |
| 225 | task_class = mapping.get(model_name, None) |
| 226 | if task_class is not None: |
| 227 | return task_class |
| 228 | |
| 229 | if throw_error_if_not_exist: |
| 230 | raise ValueError(f"AutoPipeline can't find a pipeline linked to {pipeline_class_name} for {model_name}") |
| 231 | |
| 232 | |
| 233 | class AutoPipelineForText2Image(ConfigMixin): |
no test coverage detected