# Stable diffusion img2img: Continue from saved image

**URL:** <https://discuss.huggingface.co/t/stable-diffusion-img2img-continue-from-saved-image/23535>\
**Category:** 🧨 Diffusers\
**Created:** [September 23, 2022, 11:03am UTC](https://discuss.huggingface.co/t/stable-diffusion-img2img-continue-from-saved-image/23535 "2022-09-23T11:03:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![andydhancock](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@andydhancock](https://discuss.huggingface.co/u/andydhancock)\
**Post date:** [September 23, 2022, 11:03am UTC](https://discuss.huggingface.co/t/stable-diffusion-img2img-continue-from-saved-image/23535/1 "2022-09-23T11:03:28Z")

</div>

Using the Stable diffusion img2img, I’d like to eg. do 50 steps, save to png, then do 50 steps more from the saved png using the same prompt and seed.

But it doesn’t work out right… I tried taking out the resampling line in preprocess but it does the same.

I suspect it’s something else in the preprocess but I’m not entirely sure what it does

```auto
    image = np.array(image).astype(np.float32) / 255.0
    image = image[None].transpose(0, 3, 1, 2)
    image = torch.from_numpy(image)
    return 2.0 * image - 1.0

```

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/2X/3/39d995a67c9d8b4a53e99b814af81d187a75568a.jpeg)

---

<div class="post-metadata">

**Author:** ![pcuenq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pcuenq/32/32135_2.png) [@pcuenq](https://discuss.huggingface.co/u/pcuenq)\
**Post date:** [September 23, 2022, 12:33pm UTC](https://discuss.huggingface.co/t/stable-diffusion-img2img-continue-from-saved-image/23535/2 "2022-09-23T12:33:15Z")

</div>

Hi @andydhancock thanks for writing!

In general I think it’s not safe to assume that 50 + 50 steps is the same as 100 steps, as the scheduler state changes when you launch a new generation. Some people are using callbacks to retrieve intermediate images, see for example this [github issue](https://github.com/huggingface/diffusers/pull/521).

Could you share a bit more about your use case so people can recommend other suggestions?

---

<div class="post-metadata">

**Author:** ![andydhancock](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@andydhancock](https://discuss.huggingface.co/u/andydhancock)\
**Post date:** [September 23, 2022, 1:05pm UTC](https://discuss.huggingface.co/t/stable-diffusion-img2img-continue-from-saved-image/23535/3 "2022-09-23T13:05:52Z")

</div>

Hi @pcuenq, Thanks for the reply!

It’s a twitter bot I’ve written that gives people images based on their tweet. I’d like them to be able to take one of the images it’s outputted and run a few more steps on it to perfect it a bit.  
Now a workaround will be just to see if they have requested it before and do a fresh 100 step generation on it, which I’ll probably end up doing, but I was intrigued to know why it wasn’t working as I expected…

I guess I’ve come at it with this incorrect assumption, quoted from your link:

> Granted, that last bit is _partly_ because some people start with incorrect assumptions how the inference process works and they expect the 20th step of a 100-step task will give them the same thing they see as the 20th step from a 20 step task,

---

<div class="post-metadata">

**Author:** ![pcuenq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pcuenq/32/32135_2.png) [@pcuenq](https://discuss.huggingface.co/u/pcuenq)\
**Post date:** [September 23, 2022, 1:14pm UTC](https://discuss.huggingface.co/t/stable-diffusion-img2img-continue-from-saved-image/23535/4 "2022-09-23T13:14:05Z")

</div>

Yes, I think running a fresh generation would be the way to go in this case 🙂

And this is very good feedback by the way, it’s not obvious how the process works when you start using the library. Thanks!
