Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import torch
|
|
4 |
from diffusers import StableDiffusionUpscalePipeline
|
5 |
|
6 |
# 모델 로드
|
7 |
-
pipe = StableDiffusionUpscalePipeline.from_pretrained("stabilityai/stable-diffusion-x4-upscaler"
|
8 |
|
9 |
# GPU가 사용 가능한지 확인한 후, 가능하면 GPU로 설정하고, 그렇지 않으면 CPU로 설정
|
10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -21,8 +21,9 @@ def upscale_image(image, scale_factor):
|
|
21 |
raise ValueError("지원하지 않는 배율입니다.")
|
22 |
|
23 |
# 이미지 업스케일링 수행
|
|
|
24 |
with torch.no_grad(): # 메모리 최적화를 위해 no_grad 사용
|
25 |
-
upscaled_image = pipe(image=low_res_image).images[0]
|
26 |
return upscaled_image
|
27 |
|
28 |
# Gradio 인터페이스 설정
|
@@ -50,4 +51,3 @@ def main():
|
|
50 |
|
51 |
if __name__ == "__main__":
|
52 |
main()
|
53 |
-
|
|
|
4 |
from diffusers import StableDiffusionUpscalePipeline
|
5 |
|
6 |
# 모델 로드
|
7 |
+
pipe = StableDiffusionUpscalePipeline.from_pretrained("stabilityai/stable-diffusion-x4-upscaler")
|
8 |
|
9 |
# GPU가 사용 가능한지 확인한 후, 가능하면 GPU로 설정하고, 그렇지 않으면 CPU로 설정
|
10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
21 |
raise ValueError("지원하지 않는 배율입니다.")
|
22 |
|
23 |
# 이미지 업스케일링 수행
|
24 |
+
prompt = "high quality, detailed"
|
25 |
with torch.no_grad(): # 메모리 최적화를 위해 no_grad 사용
|
26 |
+
upscaled_image = pipe(prompt=prompt, image=low_res_image).images[0]
|
27 |
return upscaled_image
|
28 |
|
29 |
# Gradio 인터페이스 설정
|
|
|
51 |
|
52 |
if __name__ == "__main__":
|
53 |
main()
|
|