You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Scheduler.from_pretrained and better scheduler changing (#1286)
* add conversion script for vae
* uP
* uP
* more changes
* push
* up
* finish again
* up
* up
* up
* up
* finish
* up
* uP
* up
* Apply suggestions from code review
Co-authored-by: Pedro Cuenca <[email protected]>
Co-authored-by: Anton Lozhkov <[email protected]>
Co-authored-by: Suraj Patil <[email protected]>
* up
* up
Co-authored-by: Pedro Cuenca <[email protected]>
Co-authored-by: Anton Lozhkov <[email protected]>
Co-authored-by: Suraj Patil <[email protected]>
The [`DiffusionPipeline`] downloads and caches all modeling, tokenization, and scheduling components.
48
48
Because the model consists of roughly 1.4 billion parameters, we strongly recommend running it on GPU.
49
49
You can move the generator object to GPU, just like you would in PyTorch.
50
50
51
51
```python
52
-
>>> generator.to("cuda")
52
+
>>> pipeline.to("cuda")
53
53
```
54
54
55
-
Now you can use the `generator` on your text prompt:
55
+
Now you can use the `pipeline` on your text prompt:
56
56
57
57
```python
58
-
>>> image =generator("An image of a squirrel in Picasso style").images[0]
58
+
>>> image =pipeline("An image of a squirrel in Picasso style").images[0]
59
59
```
60
60
61
61
The output is by default wrapped into a [PIL Image object](https://pillow.readthedocs.io/en/stable/reference/Image.html?highlight=image#the-image-class).
@@ -82,7 +82,7 @@ just like we did before only that now you need to pass your `AUTH_TOKEN`:
- First, the scheduler is loaded with [`ConfigMixin.from_config`] since it only depends on a configuration file and not any parameterized weights
148
+
- First, the scheduler is loaded with [`SchedulerMixin.from_pretrained`]
149
149
- Second, the scheduler is loaded with a function argument, called `subfolder="scheduler"` as the configuration of stable diffusion's scheduling is defined in a [subfolder of the official pipeline repository](https://huggingface.co/runwayml/stable-diffusion-v1-5/tree/main/scheduler)
150
150
- Third, the scheduler instance can simply be passed with the `scheduler` keyword argument to [`DiffusionPipeline.from_pretrained`]. This works because the [`StableDiffusionPipeline`] defines its scheduler with the `scheduler` attribute. It's not possible to use a different name, such as `sampler=scheduler` since `sampler` is not a defined keyword for [`StableDiffusionPipeline.__init__`]
151
151
@@ -337,8 +337,8 @@ model = UNet2DModel.from_pretrained(repo_id)
337
337
338
338
## Loading schedulers
339
339
340
-
Schedulers cannot be loaded via a `from_pretrained` method, but instead rely on [`ConfigMixin.from_config`]. Schedulers are **not parameterized** or **trained**, but instead purely defined by a configuration file.
341
-
Therefore the loading method was given a different name here.
340
+
Schedulers rely on [`SchedulerMixin.from_pretrained`]. Schedulers are **not parameterized** or **trained**, but instead purely defined by a configuration file.
341
+
For consistency, we use the same method name as we do for models or pipelines, but no weights are loaded in this case.
342
342
343
343
In constrast to pipelines or models, loading schedulers does not consume any significant amount of memory and the same configuration file can often be used for a variety of different schedulers.
0 commit comments