fantaxy commited on
Commit
584b0b8
·
verified ·
1 Parent(s): 586370e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -9
app.py CHANGED
@@ -48,7 +48,28 @@ import cv2
48
  import numpy as np
49
  import sys
50
  import io
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
 
 
 
 
52
  logging.basicConfig(level=logging.INFO)
53
  logger = logging.getLogger(__name__)
54
 
@@ -138,15 +159,6 @@ class timer:
138
  end = time.time()
139
  print(f"{self.method} took {str(round(end - self.start, 2))}s")
140
 
141
- # Model initialization
142
- if not path.exists(cache_path):
143
- os.makedirs(cache_path, exist_ok=True)
144
-
145
- pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16)
146
- pipe.load_lora_weights(hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors"))
147
- pipe.fuse_lora(lora_scale=0.125)
148
- pipe.to(device="cuda", dtype=torch.bfloat16)
149
- pipe.safety_checker = safety_checker.StableDiffusionSafetyChecker.from_pretrained("CompVis/stable-diffusion-safety-checker")
150
 
151
  def upload_to_catbox(image_path):
152
  """catbox.moe API를 사용하여 이미지 업로드"""
 
48
  import numpy as np
49
  import sys
50
  import io
51
+ # FluxPipeline import 부분을 수정
52
+ from diffusers import StableDiffusionPipeline, DiffusionPipeline
53
+ from diffusers.pipelines.stable_diffusion import StableDiffusionPipelineOutput
54
+
55
+ # 기존의 pipe 초기화 부분을 다음과 같이 수정
56
+ pipe = StableDiffusionPipeline.from_pretrained(
57
+ "stabilityai/stable-diffusion-2-1",
58
+ torch_dtype=torch.float16,
59
+ safety_checker=None
60
+ )
61
+ pipe.to("cuda")
62
+
63
+ # LoRA 가중치 로드
64
+ pipe.load_lora_weights(
65
+ hf_hub_download("ByteDance/Hyper-SD", "Hyper-FLUX.1-dev-8steps-lora.safetensors")
66
+ )
67
+ pipe.fuse_lora(lora_scale=0.125)
68
 
69
+ # 안전 검사기 설정
70
+ pipe.safety_checker = safety_checker.StableDiffusionSafetyChecker.from_pretrained(
71
+ "CompVis/stable-diffusion-safety-checker"
72
+ )
73
  logging.basicConfig(level=logging.INFO)
74
  logger = logging.getLogger(__name__)
75
 
 
159
  end = time.time()
160
  print(f"{self.method} took {str(round(end - self.start, 2))}s")
161
 
 
 
 
 
 
 
 
 
 
162
 
163
  def upload_to_catbox(image_path):
164
  """catbox.moe API를 사용하여 이미지 업로드"""