# Upscaling an Anime Image using Diffusers

**URL:** <https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861>\
**Category:** 🧨 Diffusers\
**Created:** [August 7, 2023, 7:34pm UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861 "2023-08-07T19:34:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![futuristsenpai](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/futuristsenpai/32/18354_2.png) [@futuristsenpai](https://discuss.huggingface.co/u/futuristsenpai)\
**Post date:** [August 7, 2023, 7:34pm UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861/1 "2023-08-07T19:34:47Z")

</div>

Hi community, I’m probably doing something really wrong, but, I’m trying to create an anime image using dreamlike/anime. I’m getting a low res image first to evaluate if it is ok, and then I need to upscale it.

```auto
from diffusers import StableDiffusionPipeline
import torch

generator = torch.manual_seed(100)
def get_image(prompt, model_id = "dreamlike-art/dreamlike-anime-1.0"):
  #model_id = "dreamlike-art/dreamlike-anime-1.0"
  pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
  pipe = pipe.to("cuda")
  negative_prompt = 'simple background, duplicate, retro style, low quality, lowest quality, 1980s, 1990s, 2000s, 2005 2006 2007 2008 2009 2010 2011 2012 2013, bad anatomy, bad proportions, extra digits, lowres, username, artist name, error, duplicate, watermark, signature, text, extra digit, fewer digits, worst quality,jpeg artifacts, blurry'
  low_res_latents = pipe(prompt, height=512, width=768, guidance_scale=7.5, negative_prompt=negative_prompt, output_type="latent").images
  with torch.no_grad():
    image = pipe.decode_latents(low_res_latents)
  image = pipe.numpy_to_pil(image)[0]

  image.save("a1.png")

  return low_res_latents

```

Then I try to upscale it and got really weird results specially in the eyes:

```auto
from diffusers import StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline

def upscale(image, name):
  model_id = "stabilityai/sd-x2-latent-upscaler"
  upscaler = StableDiffusionLatentUpscalePipeline.from_pretrained(model_id, torch_dtype=torch.float16)
  upscaler.to("cuda")
  upscaled_image = upscaler(
      prompt=prompt,
      image=low_res_latents,
      num_inference_steps=20,
      guidance_scale=0,
      generator=generator,
  ).images[0]
  upscaled_image.save(name)
  return upscaled_image

```

Also it pixelates too much the new image, am I doing something wrong??

---

<div class="post-metadata">

**Author:** ![futuristsenpai](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/futuristsenpai/32/18354_2.png) [@futuristsenpai](https://discuss.huggingface.co/u/futuristsenpai)\
**Post date:** [August 7, 2023, 8:11pm UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861/2 "2023-08-07T20:11:58Z")

</div>

Here are the examples of the output:  
Low Res:

 ![low-res-latent](https://us1.discourse-cdn.com/hellohellohello/original/3X/4/9/49ed82ca1b81a729348283049cb31977313d9015.jpeg)

---

<div class="post-metadata">

**Author:** ![futuristsenpai](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/futuristsenpai/32/18354_2.png) [@futuristsenpai](https://discuss.huggingface.co/u/futuristsenpai)\
**Post date:** [August 7, 2023, 8:12pm UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861/3 "2023-08-07T20:12:29Z")

</div>

Upscaled x2:

 ![upscaled](https://us1.discourse-cdn.com/hellohellohello/original/3X/5/5/559eb6efab6bd960a201d4ea3d6039770533756e.jpeg)

---

<div class="post-metadata">

**Author:** ![futuristsenpai](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/futuristsenpai/32/18354_2.png) [@futuristsenpai](https://discuss.huggingface.co/u/futuristsenpai)\
**Post date:** [August 8, 2023, 8:20pm UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861/4 "2023-08-08T20:20:08Z")

</div>

Here is a good alternative 🙂 [Improving Diffusers Package for High-Quality Image Generation | by Andrew Zhu | Towards Data Science](https://towardsdatascience.com/improving-diffusers-package-for-high-quality-image-generation-a50fff04bdd4)

---

<div class="post-metadata">

**Author:** ![deai140630](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@deai140630](https://discuss.huggingface.co/u/deai140630)\
**Post date:** [September 14, 2023, 2:09am UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861/5 "2023-09-14T02:09:31Z")

</div>

Hi, I meet the same problem using img2img with adetailer, do you find the way to solve this?

generated image:

 ![qwer](https://us1.discourse-cdn.com/hellohellohello/original/3X/c/e/ce5207cf20c1df5645d1a89baa0c4bb5b312cd28.jpeg)

---

<div class="post-metadata">

**Author:** ![futuristsenpai](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/futuristsenpai/32/18354_2.png) [@futuristsenpai](https://discuss.huggingface.co/u/futuristsenpai)\
**Post date:** [September 14, 2023, 10:11am UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861/6 "2023-09-14T10:11:48Z")

</div>

Hi, i’ve found this workaround [Improving Diffusers Package for High-Quality Image Generation | by Andrew Zhu | Towards Data Science](https://towardsdatascience.com/improving-diffusers-package-for-high-quality-image-generation-a50fff04bdd4) with parameter strength at 0.3

---

<div class="post-metadata">

**Author:** ![deai140630](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@deai140630](https://discuss.huggingface.co/u/deai140630)\
**Post date:** [September 14, 2023, 10:56am UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861/7 "2023-09-14T10:56:21Z")

</div>

I also find the reason too, thanks your attension. I forget to set : use\_karras\_sigmas=True, when using  
DPM++ 2M Karras in diffusers.

[A1111 \<\> Diffusers Scheduler mapping · Issue #4167 · huggingface/diffusers (github.com)](https://github.com/huggingface/diffusers/issues/4167)

 ![image](https://us1.discourse-cdn.com/hellohellohello/original/3X/7/e/7e8413c187f28c1ccb18d752a8986f65f7139fdf.png)

---

<div class="post-metadata">

**Author:** ![philz1337x](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/philz1337x/32/31420_2.png) [@philz1337x](https://discuss.huggingface.co/u/philz1337x)\
**Post date:** [September 9, 2024, 9:57am UTC](https://discuss.huggingface.co/t/upscaling-an-anime-image-using-diffusers/49861/8 "2024-09-09T09:57:28Z")

</div>

I would try to upscale using im2img with a higher resolution.

also you can use Clarity upscaler ([Clarity AI | #1 AI Image Upscaler & Enhancer](https://clarityai.co/anime-image-upscaling)) for free in automatic 1111 (sorry not diffusers) : [x.com](https://x.com/philz1337x/status/1773342568543346738)
