# Why 'DiffusionPipeline' doesn't have a \_\_call\_\_ method?

**URL:** <https://discuss.huggingface.co/t/why-diffusionpipeline-doesnt-have-a-call-method/43175>\
**Category:** 🧨 Diffusers\
**Created:** [June 14, 2023, 8:29am UTC](https://discuss.huggingface.co/t/why-diffusionpipeline-doesnt-have-a-call-method/43175 "2023-06-14T08:29:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LiuPT](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@LiuPT](https://discuss.huggingface.co/u/LiuPT)\
**Post date:** [June 14, 2023, 8:29am UTC](https://discuss.huggingface.co/t/why-diffusionpipeline-doesnt-have-a-call-method/43175/1 "2023-06-14T08:29:50Z")

</div>

Every pipeline has a ` __call__ ` method which keeps them can call themselves as a function. But I can’t find ` __call__ ` method in class `DiffusionPipeline`.  
I read DiffusionPipeline code and find nothing about ` __call__ ` method in this link:  
[DiffusionPipeline](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L1404)  
Why?  
In this link [train\_dreambooth.py](https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py#L163)  
you can see that DiffusionPipeline do used **call** function, so that it can make a inference.  
May someone can teach me about this, thanks a lot.  
PS:sorry for my poor English

---

<div class="post-metadata">

**Author:** ![mnslarcher](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/mnslarcher/32/17842_2.png) [@mnslarcher](https://discuss.huggingface.co/u/mnslarcher)\
**Post date:** [August 4, 2023, 5:00pm UTC](https://discuss.huggingface.co/t/why-diffusionpipeline-doesnt-have-a-call-method/43175/2 "2023-08-04T17:00:47Z")

</div>

If you use the `from_pretrained` method of the `DiffusionPipeline` like this:

```python
from diffusers import DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")

```

The resulting `pipe` is not only an instance of the `DiffusionPipeline` class but also, in this case, an instance of the `StableDiffusionXLPipeline` class. You can verify this as follows:

```python
from diffusers import StableDiffusionXLPipeline

isinstance(pipe, DiffusionPipeline) and isinstance(pipe, StableDiffusionXLPipeline)

```

Output:

```bash
True

```

This method internally instantiates an object of the `StableDiffusionXLPipeline` class, and similar to other pipelines, this class defines a [` __call__ ` method](https://github.com/huggingface/diffusers/blob/de9c72d58c3eb4bcd50901d0c23c7c46f0cec29b/src/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py#L559).

Please be aware that the `DiffusionPipeline` lacks also an ` __init__ ` method. Therefore, you cannot perform the following action to instantiate and use an object of only the `DiffusionPipeline` class:

```python
pipe = DiffusionPipeline(...)

```

Instead, you are required to use the `from_pretrained` method, which returns an object from a class that defines a ` __call__ ` method.

I hope this was helpful, and fingers crossed I didn’t write any inaccuracies! 😊

---

<div class="post-metadata">

**Author:** ![LiuPT](https://avatars.discourse-cdn.com/v4/letter/l/96bed5/32.png) [@LiuPT](https://discuss.huggingface.co/u/LiuPT)\
**Post date:** [January 2, 2024, 6:43am UTC](https://discuss.huggingface.co/t/why-diffusionpipeline-doesnt-have-a-call-method/43175/3 "2024-01-02T06:43:50Z")

</div>

OK,thanks a lot! That’s really helpful!
