aptol commited on
Commit
a4d6f85
·
verified ·
1 Parent(s): 18a6def

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -19
app.py CHANGED
@@ -867,28 +867,37 @@ def step1_gpu_refine(
867
 
868
  # ---- (옵션) 리드로우(img2img)
869
  if do_redraw_flag:
870
- from diffusers import StableDiffusionImg2ImgPipeline
871
- pr = StableDiffusionImg2ImgPipeline.from_pretrained(
872
- "runwayml/stable-diffusion-v1-5", torch_dtype=dtype,
873
- safety_checker=None, feature_extractor=None
874
- )
875
- pr = _disable_safety(pr)
876
- if dev == "cuda": pr.to("cuda")
877
- img_for = _resize_to_multiple(img.convert("RGB"), 8, 640)
878
- img = pr(
879
- prompt="clean anime illustration, sharp lines, flat colors, plain white background",
880
- negative_prompt="glitch, mosaic, text, watermark, noisy",
881
- image=img_for,
882
- strength=float(max(0.30, min(0.45, float(redraw_strength)))),
883
- guidance_scale=float(max(6.5, min(9.0, float(redraw_guidance)))),
884
- num_inference_steps=int(max(14, min(28, int(redraw_steps)))),
885
- ).images[0].convert("RGBA")
886
-
887
- img.save(OUT/"step1"/"dbg_05_after_redraw.png") # 들여쓰기 맞춤
888
- logs.append("img2img 리드로우 적용") # ✅ 들여쓰기 맞춤
 
 
 
 
 
 
 
 
889
  except Exception as e:
890
  logs.append(f"img2img 리드로우 실패: {e}")
891
 
 
892
  # ---- 저장 & 프리뷰
893
  out_path = _save_png(img, OUT / "step1" / "input_preprocessed.png")
894
  try:
 
867
 
868
  # ---- (옵션) 리드로우(img2img)
869
  if do_redraw_flag:
870
+ try:
871
+ from diffusers import StableDiffusionImg2ImgPipeline
872
+ pr = StableDiffusionImg2ImgPipeline.from_pretrained(
873
+ "runwayml/stable-diffusion-v1-5",
874
+ torch_dtype=dtype,
875
+ safety_checker=None,
876
+ feature_extractor=None
877
+ )
878
+
879
+ pr = _disable_safety(pr)
880
+ if dev == "cuda":
881
+ pr.to("cuda")
882
+
883
+ img_for = _resize_to_multiple(img.convert("RGB"), 8, 640)
884
+
885
+ img = pr(
886
+ prompt="clean anime illustration, sharp lines, flat colors, plain white background",
887
+ negative_prompt="glitch, mosaic, text, watermark, noisy",
888
+ image=img_for,
889
+ strength=float(max(0.30, min(0.45, float(redraw_strength)))),
890
+ guidance_scale=float(max(6.5, min(9.0, float(redraw_guidance)))),
891
+ num_inference_steps=int(max(14, min(28, int(redraw_steps))))
892
+ ).images[0].convert("RGBA")
893
+
894
+ img.save(OUT/"step1"/"dbg_05_after_redraw.png")
895
+ logs.append("img2img 리드로우 적용")
896
+
897
  except Exception as e:
898
  logs.append(f"img2img 리드로우 실패: {e}")
899
 
900
+
901
  # ---- 저장 & 프리뷰
902
  out_path = _save_png(img, OUT / "step1" / "input_preprocessed.png")
903
  try: