|
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
15 | 15 |
|
16 | | -import inspect |
17 | 16 | from collections import OrderedDict |
18 | 17 |
|
19 | 18 | from huggingface_hub.utils import validate_hf_hub_args |
@@ -164,14 +163,6 @@ def get_model(pipeline_class_name): |
164 | 163 | raise ValueError(f"AutoPipeline can't find a pipeline linked to {pipeline_class_name} for {model_name}") |
165 | 164 |
|
166 | 165 |
|
167 | | -def _get_signature_keys(obj): |
168 | | - parameters = inspect.signature(obj.__init__).parameters |
169 | | - required_parameters = {k: v for k, v in parameters.items() if v.default == inspect._empty} |
170 | | - optional_parameters = set({k for k, v in parameters.items() if v.default != inspect._empty}) |
171 | | - expected_modules = set(required_parameters.keys()) - {"self"} |
172 | | - return expected_modules, optional_parameters |
173 | | - |
174 | | - |
175 | 166 | class AutoPipelineForText2Image(ConfigMixin): |
176 | 167 | r""" |
177 | 168 |
|
@@ -391,7 +382,7 @@ def from_pipe(cls, pipeline, **kwargs): |
391 | 382 | ) |
392 | 383 |
|
393 | 384 | # define expected module and optional kwargs given the pipeline signature |
394 | | - expected_modules, optional_kwargs = _get_signature_keys(text_2_image_cls) |
| 385 | + expected_modules, optional_kwargs = text_2_image_cls._get_signature_keys(text_2_image_cls) |
395 | 386 |
|
396 | 387 | pretrained_model_name_or_path = original_config.pop("_name_or_path", None) |
397 | 388 |
|
@@ -668,7 +659,7 @@ def from_pipe(cls, pipeline, **kwargs): |
668 | 659 | ) |
669 | 660 |
|
670 | 661 | # define expected module and optional kwargs given the pipeline signature |
671 | | - expected_modules, optional_kwargs = _get_signature_keys(image_2_image_cls) |
| 662 | + expected_modules, optional_kwargs = image_2_image_cls._get_signature_keys(image_2_image_cls) |
672 | 663 |
|
673 | 664 | pretrained_model_name_or_path = original_config.pop("_name_or_path", None) |
674 | 665 |
|
@@ -943,7 +934,7 @@ def from_pipe(cls, pipeline, **kwargs): |
943 | 934 | ) |
944 | 935 |
|
945 | 936 | # define expected module and optional kwargs given the pipeline signature |
946 | | - expected_modules, optional_kwargs = _get_signature_keys(inpainting_cls) |
| 937 | + expected_modules, optional_kwargs = inpainting_cls._get_signature_keys(inpainting_cls) |
947 | 938 |
|
948 | 939 | pretrained_model_name_or_path = original_config.pop("_name_or_path", None) |
949 | 940 |
|
|
0 commit comments