emirhanbilgic commited on
Commit
64da1cb
1 Parent(s): dcda2e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -15,6 +15,7 @@ import torch
15
  from diffusers import StableDiffusionPipeline, StableDiffusionControlNetInpaintPipeline, ControlNetModel
16
  from PIL import Image
17
  from compel import Compel
 
18
 
19
  # Device configuration
20
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
@@ -40,6 +41,10 @@ pipe = StableDiffusionControlNetInpaintPipeline.from_pretrained(
40
  torch_dtype=torch.float16,
41
  ).to(device)
42
 
 
 
 
 
43
  # Function to segment hair and generate mask
44
  def segment_hair(image):
45
  rgba_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGBA)
@@ -89,7 +94,7 @@ def inpaint_hair(image, prompt):
89
  image=image_pil,
90
  mask_image=mask_pil,
91
  control_image=inpaint_condition,
92
- num_inference_steps=50,
93
  guidance_scale=7.5,
94
  generator=generator
95
  ).images[0]
 
15
  from diffusers import StableDiffusionPipeline, StableDiffusionControlNetInpaintPipeline, ControlNetModel
16
  from PIL import Image
17
  from compel import Compel
18
+ from diffusers import EulerDiscreteScheduler
19
 
20
  # Device configuration
21
  device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
 
41
  torch_dtype=torch.float16,
42
  ).to(device)
43
 
44
+
45
+ # Set the K_EULER scheduler
46
+ pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config)
47
+
48
  # Function to segment hair and generate mask
49
  def segment_hair(image):
50
  rgba_image = cv2.cvtColor(image, cv2.COLOR_BGR2RGBA)
 
94
  image=image_pil,
95
  mask_image=mask_pil,
96
  control_image=inpaint_condition,
97
+ num_inference_steps=25,
98
  guidance_scale=7.5,
99
  generator=generator
100
  ).images[0]