Skip to content

Commit 14e3a28

Browse files
authored
Rename 'CLIPFeatureExtractor' class to 'CLIPImageProcessor' (#2732)
The 'CLIPFeatureExtractor' class name has been renamed to 'CLIPImageProcessor' in order to comply with future deprecation. This commit includes the necessary changes to the affected files.
1 parent 8e35ef0 commit 14e3a28

File tree

64 files changed

+181
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+181
-181
lines changed

docs/source/en/api/pipelines/overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ components - all of which are needed to have a functioning end-to-end diffusion
1919
As an example, [Stable Diffusion](https://huggingface.co/blog/stable_diffusion) has three independently trained models:
2020
- [Autoencoder](./api/models#vae)
2121
- [Conditional Unet](./api/models#UNet2DConditionModel)
22-
- [CLIP text encoder](https://huggingface.co/docs/transformers/v4.21.2/en/model_doc/clip#transformers.CLIPTextModel)
22+
- [CLIP text encoder](https://huggingface.co/docs/transformers/v4.27.1/en/model_doc/clip#transformers.CLIPTextModel)
2323
- a scheduler component, [scheduler](./api/scheduler#pndm),
24-
- a [CLIPFeatureExtractor](https://huggingface.co/docs/transformers/v4.21.2/en/model_doc/clip#transformers.CLIPFeatureExtractor),
24+
- a [CLIPImageProcessor](https://huggingface.co/docs/transformers/v4.27.1/en/model_doc/clip#transformers.CLIPImageProcessor),
2525
- as well as a [safety checker](./stable_diffusion#safety_checker).
2626
All of these components are necessary to run stable diffusion in inference even though they were trained
2727
or created independently from each other.

docs/source/en/using-diffusers/custom_pipeline_examples.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ The following code requires roughly 12GB of GPU RAM.
4545

4646
```python
4747
from diffusers import DiffusionPipeline
48-
from transformers import CLIPFeatureExtractor, CLIPModel
48+
from transformers import CLIPImageProcessor, CLIPModel
4949
import torch
5050

5151

52-
feature_extractor = CLIPFeatureExtractor.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K")
52+
feature_extractor = CLIPImageProcessor.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K")
5353
clip_model = CLIPModel.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K", torch_dtype=torch.float16)
5454

5555

docs/source/en/using-diffusers/custom_pipeline_overview.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ and passing pipeline modules directly.
5050

5151
```python
5252
from diffusers import DiffusionPipeline
53-
from transformers import CLIPFeatureExtractor, CLIPModel
53+
from transformers import CLIPImageProcessor, CLIPModel
5454

5555
clip_model_id = "laion/CLIP-ViT-B-32-laion2B-s34B-b79K"
5656

57-
feature_extractor = CLIPFeatureExtractor.from_pretrained(clip_model_id)
57+
feature_extractor = CLIPImageProcessor.from_pretrained(clip_model_id)
5858
clip_model = CLIPModel.from_pretrained(clip_model_id)
5959

6060
pipeline = DiffusionPipeline.from_pretrained(

docs/source/en/using-diffusers/loading.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ print(pipe)
415415
StableDiffusionPipeline {
416416
"feature_extractor": [
417417
"transformers",
418-
"CLIPFeatureExtractor"
418+
"CLIPImageProcessor"
419419
],
420420
"safety_checker": [
421421
"stable_diffusion",
@@ -445,7 +445,7 @@ StableDiffusionPipeline {
445445
```
446446

447447
First, we see that the official pipeline is the [`StableDiffusionPipeline`], and second we see that the `StableDiffusionPipeline` consists of 7 components:
448-
- `"feature_extractor"` of class `CLIPFeatureExtractor` as defined [in `transformers`](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPFeatureExtractor).
448+
- `"feature_extractor"` of class `CLIPImageProcessor` as defined [in `transformers`](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor).
449449
- `"safety_checker"` as defined [here](https://github.com/huggingface/diffusers/blob/e55687e1e15407f60f32242027b7bb8170e58266/src/diffusers/pipelines/stable_diffusion/safety_checker.py#L32).
450450
- `"scheduler"` of class [`PNDMScheduler`].
451451
- `"text_encoder"` of class `CLIPTextModel` as defined [in `transformers`](https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModel).
@@ -493,7 +493,7 @@ In the case of `runwayml/stable-diffusion-v1-5` the `model_index.json` is theref
493493
"_diffusers_version": "0.6.0",
494494
"feature_extractor": [
495495
"transformers",
496-
"CLIPFeatureExtractor"
496+
"CLIPImageProcessor"
497497
],
498498
"safety_checker": [
499499
"stable_diffusion",

examples/community/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ The following code requires roughly 12GB of GPU RAM.
5050

5151
```python
5252
from diffusers import DiffusionPipeline
53-
from transformers import CLIPFeatureExtractor, CLIPModel
53+
from transformers import CLIPImageProcessor, CLIPModel
5454
import torch
5555

5656

57-
feature_extractor = CLIPFeatureExtractor.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K")
57+
feature_extractor = CLIPImageProcessor.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K")
5858
clip_model = CLIPModel.from_pretrained("laion/CLIP-ViT-B-32-laion2B-s34B-b79K", torch_dtype=torch.float16)
5959

6060

examples/community/clip_guided_stable_diffusion.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from torch import nn
66
from torch.nn import functional as F
77
from torchvision import transforms
8-
from transformers import CLIPFeatureExtractor, CLIPModel, CLIPTextModel, CLIPTokenizer
8+
from transformers import CLIPImageProcessor, CLIPModel, CLIPTextModel, CLIPTokenizer
99

1010
from diffusers import (
1111
AutoencoderKL,
@@ -64,7 +64,7 @@ def __init__(
6464
tokenizer: CLIPTokenizer,
6565
unet: UNet2DConditionModel,
6666
scheduler: Union[PNDMScheduler, LMSDiscreteScheduler, DDIMScheduler],
67-
feature_extractor: CLIPFeatureExtractor,
67+
feature_extractor: CLIPImageProcessor,
6868
):
6969
super().__init__()
7070
self.register_modules(

examples/community/composable_stable_diffusion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import torch
1919
from packaging import version
20-
from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
20+
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
2121

2222
from diffusers import DiffusionPipeline
2323
from diffusers.configuration_utils import FrozenDict
@@ -64,7 +64,7 @@ class ComposableStableDiffusionPipeline(DiffusionPipeline):
6464
safety_checker ([`StableDiffusionSafetyChecker`]):
6565
Classification module that estimates whether generated images could be considered offensive or harmful.
6666
Please, refer to the [model card](https://huggingface.co/runwayml/stable-diffusion-v1-5) for details.
67-
feature_extractor ([`CLIPFeatureExtractor`]):
67+
feature_extractor ([`CLIPImageProcessor`]):
6868
Model that extracts features from generated images to be used as inputs for the `safety_checker`.
6969
"""
7070
_optional_components = ["safety_checker", "feature_extractor"]
@@ -84,7 +84,7 @@ def __init__(
8484
DPMSolverMultistepScheduler,
8585
],
8686
safety_checker: StableDiffusionSafetyChecker,
87-
feature_extractor: CLIPFeatureExtractor,
87+
feature_extractor: CLIPImageProcessor,
8888
requires_safety_checker: bool = True,
8989
):
9090
super().__init__()

examples/community/imagic_stable_diffusion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# TODO: remove and import from diffusers.utils when the new version of diffusers is released
1616
from packaging import version
1717
from tqdm.auto import tqdm
18-
from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
18+
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
1919

2020
from diffusers import DiffusionPipeline
2121
from diffusers.models import AutoencoderKL, UNet2DConditionModel
@@ -80,7 +80,7 @@ class ImagicStableDiffusionPipeline(DiffusionPipeline):
8080
safety_checker ([`StableDiffusionSafetyChecker`]):
8181
Classification module that estimates whether generated images could be considered offsensive or harmful.
8282
Please, refer to the [model card](https://huggingface.co/CompVis/stable-diffusion-v1-4) for details.
83-
feature_extractor ([`CLIPFeatureExtractor`]):
83+
feature_extractor ([`CLIPImageProcessor`]):
8484
Model that extracts features from generated images to be used as inputs for the `safety_checker`.
8585
"""
8686

@@ -92,7 +92,7 @@ def __init__(
9292
unet: UNet2DConditionModel,
9393
scheduler: Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler],
9494
safety_checker: StableDiffusionSafetyChecker,
95-
feature_extractor: CLIPFeatureExtractor,
95+
feature_extractor: CLIPImageProcessor,
9696
):
9797
super().__init__()
9898
self.register_modules(

examples/community/img2img_inpainting.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55
import PIL
66
import torch
7-
from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
7+
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
88

99
from diffusers import DiffusionPipeline
1010
from diffusers.configuration_utils import FrozenDict
@@ -79,7 +79,7 @@ class ImageToImageInpaintingPipeline(DiffusionPipeline):
7979
safety_checker ([`StableDiffusionSafetyChecker`]):
8080
Classification module that estimates whether generated images could be considered offensive or harmful.
8181
Please, refer to the [model card](https://huggingface.co/runwayml/stable-diffusion-v1-5) for details.
82-
feature_extractor ([`CLIPFeatureExtractor`]):
82+
feature_extractor ([`CLIPImageProcessor`]):
8383
Model that extracts features from generated images to be used as inputs for the `safety_checker`.
8484
"""
8585

@@ -91,7 +91,7 @@ def __init__(
9191
unet: UNet2DConditionModel,
9292
scheduler: Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler],
9393
safety_checker: StableDiffusionSafetyChecker,
94-
feature_extractor: CLIPFeatureExtractor,
94+
feature_extractor: CLIPImageProcessor,
9595
):
9696
super().__init__()
9797

examples/community/interpolate_stable_diffusion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import numpy as np
77
import torch
8-
from transformers import CLIPFeatureExtractor, CLIPTextModel, CLIPTokenizer
8+
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer
99

1010
from diffusers import DiffusionPipeline
1111
from diffusers.configuration_utils import FrozenDict
@@ -70,7 +70,7 @@ class StableDiffusionWalkPipeline(DiffusionPipeline):
7070
safety_checker ([`StableDiffusionSafetyChecker`]):
7171
Classification module that estimates whether generated images could be considered offensive or harmful.
7272
Please, refer to the [model card](https://huggingface.co/CompVis/stable-diffusion-v1-4) for details.
73-
feature_extractor ([`CLIPFeatureExtractor`]):
73+
feature_extractor ([`CLIPImageProcessor`]):
7474
Model that extracts features from generated images to be used as inputs for the `safety_checker`.
7575
"""
7676

@@ -82,7 +82,7 @@ def __init__(
8282
unet: UNet2DConditionModel,
8383
scheduler: Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler],
8484
safety_checker: StableDiffusionSafetyChecker,
85-
feature_extractor: CLIPFeatureExtractor,
85+
feature_extractor: CLIPImageProcessor,
8686
):
8787
super().__init__()
8888

0 commit comments

Comments
 (0)