hirol commited on
Commit
85a1afb
1 Parent(s): e48f389

Update generate_img.py

Browse files
Files changed (1) hide show
  1. generate_img.py +8 -22
generate_img.py CHANGED
@@ -7,10 +7,16 @@ from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet i
7
  import random
8
 
9
  # model2
 
 
 
 
 
 
10
  controlnet = ControlNetModel.from_pretrained("hirol/control_any5_openpose", torch_dtype=torch.float16)
11
  pipe = StableDiffusionControlNetInpaintPipeline.from_pretrained("hirol/Any-inpainting", controlnet=controlnet, torch_dtype=torch.float16)
12
  pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
13
-
14
 
15
  def make_inpaint_condition(image, image_mask):
16
  image = np.array(image.convert("RGB")).astype(np.float32) / 255.0
@@ -23,16 +29,6 @@ def make_inpaint_condition(image, image_mask):
23
 
24
 
25
  def generate_image(prompt:str, negative_prompt:str, openpose_image, original_image, mask_image):
26
- # model1
27
- controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_openpose", torch_dtype=torch.float16,
28
- cache_dir='./models')
29
- pipe = StableDiffusionControlNetInpaintPipeline.from_pretrained(
30
- "./models/Any-inpainting", controlnet=controlnet, torch_dtype=torch.float16, cache_dir='./models'
31
- )
32
-
33
- pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
34
- pipe.to('cuda')
35
-
36
  a = random.randint(10000,90000)
37
  generator = torch.manual_seed(a)
38
  # control_image = make_inpaint_condition(original_image, mask_image)
@@ -56,17 +52,7 @@ def generate_image(prompt:str, negative_prompt:str, openpose_image, original_ima
56
  def generate_image_sketch(prompt: str, negative_prompt: str, openpose_image, original_image, mask_image):
57
  b = random.randint(10000, 90000)
58
  generator = torch.manual_seed(b)
59
- # model2
60
- controlnet1 = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_scribble", torch_dtype=torch.float16,
61
- cache_dir='./models')
62
-
63
- pipe1 = StableDiffusionControlNetInpaintPipeline.from_pretrained(
64
- "./models/Any-inpainting", controlnet=controlnet1, torch_dtype=torch.float16, cache_dir='./models'
65
- )
66
-
67
- pipe1.scheduler = UniPCMultistepScheduler.from_config(pipe1.scheduler.config)
68
- pipe1.to('cuda')
69
-
70
  image = pipe1(
71
  prompt=prompt,
72
  # images,
 
7
  import random
8
 
9
  # model2
10
+ controlnet1 = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_scribble", torch_dtype=torch.float16)
11
+ pipe1 = StableDiffusionControlNetInpaintPipeline.from_pretrained("hirol/Any-inpainting", controlnet=controlnet1, torch_dtype=torch.float16)
12
+ pipe1.scheduler = UniPCMultistepScheduler.from_config(pipe1.scheduler.config)
13
+ pipe1.to('cuda')
14
+
15
+ # model1
16
  controlnet = ControlNetModel.from_pretrained("hirol/control_any5_openpose", torch_dtype=torch.float16)
17
  pipe = StableDiffusionControlNetInpaintPipeline.from_pretrained("hirol/Any-inpainting", controlnet=controlnet, torch_dtype=torch.float16)
18
  pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
19
+ pipe.to('cuda')
20
 
21
  def make_inpaint_condition(image, image_mask):
22
  image = np.array(image.convert("RGB")).astype(np.float32) / 255.0
 
29
 
30
 
31
  def generate_image(prompt:str, negative_prompt:str, openpose_image, original_image, mask_image):
 
 
 
 
 
 
 
 
 
 
32
  a = random.randint(10000,90000)
33
  generator = torch.manual_seed(a)
34
  # control_image = make_inpaint_condition(original_image, mask_image)
 
52
  def generate_image_sketch(prompt: str, negative_prompt: str, openpose_image, original_image, mask_image):
53
  b = random.randint(10000, 90000)
54
  generator = torch.manual_seed(b)
55
+
 
 
 
 
 
 
 
 
 
 
56
  image = pipe1(
57
  prompt=prompt,
58
  # images,