728x90
반응형
diffusion을 기반으로 하는 image upscale 모델이 아주 많은데요.
많이 쓰이는 모델 중 하나인 sd-x2-latent-upscaler를 이용해 image upscale을 진행해보겠습니다.
전체 코드는 아래와 같습니다.
from diffusers import StableDiffusionLatentUpscalePipeline
import torch
upscaler = StableDiffusionLatentUpscalePipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float16)
upscaler.to("cuda")
prompt = "(photorealistic:1.4), best quality"
generator = torch.manual_seed(42)
low_res_latents = Image.open("image.png")
upscaled_image = upscaler(
prompt=prompt,
image=low_res_latents,
num_inference_steps=20,
guidance_scale=0,
generator=generator,
).images[0]
upscaled_image.save("result.png")
inference_step 은 20만 진행해주겠습니다.
- before
- after
기존 화질 손상 없이 잘 upscale 되었습니다.
728x90
반응형
'Etc' 카테고리의 다른 글
[lmdb] lmdb 파일 쓰기 및 읽기 (1) | 2025.01.23 |
---|---|
safetensor 모델을 diffusers에서 사용 가능하게 변경하기 (0) | 2024.11.11 |
[JNI] jbyte를 C++의 vector<uchar>로 변환하는 방법 (0) | 2023.03.12 |
[JNI] JNI 사용법 및 튜토리얼 (2) (0) | 2023.03.12 |
[JNI] JNI 사용법 및 튜토리얼 (1) (3) | 2023.03.11 |