Make ImageProcessorMixin compatible with subfolder kwarg (#21725)

* Add subfolder support

* Add kwarg docstring

* formatting fix

* Add test
This commit is contained in:
Naga Sai Abhinay
2023-02-23 13:58:18 +05:30
committed by GitHub
parent 064f374874
commit 448e050b0d
2 changed files with 19 additions and 0 deletions

View File

@@ -311,3 +311,14 @@ class ImageProcessorPushToHubTester(unittest.TestCase):
)
# Can't make an isinstance check because the new_image_processor is from the CustomImageProcessor class of a dynamic module
self.assertEqual(new_image_processor.__class__.__name__, "CustomImageProcessor")
def test_image_processor_from_pretrained_subfolder(self):
with self.assertRaises(OSError):
# config is in subfolder, the following should not work without specifying the subfolder
_ = AutoImageProcessor.from_pretrained("hf-internal-testing/stable-diffusion-all-variants")
config = AutoImageProcessor.from_pretrained(
"hf-internal-testing/stable-diffusion-all-variants", subfolder="feature_extractor"
)
self.assertIsNotNone(config)