lixiang46 commited on
Commit
a1bb479
·
1 Parent(s): 9cdf8f2
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -62,13 +62,11 @@ pipe_canny = StableDiffusionXLControlNetImg2ImgPipeline(
62
  force_zeros_for_empty_prompt=False
63
  )
64
 
65
- @spaces.GPU
66
- def load_ipa(pipe):
67
  if hasattr(pipe.unet, 'encoder_hid_proj'):
68
  pipe.unet.text_encoder_hid_proj = pipe.unet.encoder_hid_proj
69
 
70
  pipe.load_ip_adapter(f'{ckpt_dir_ipa}' , subfolder="", weight_name=["ip_adapter_plus_general.bin"])
71
- return pipe
72
 
73
  @spaces.GPU
74
  def process_canny_condition(image, canny_threods=[100,200]):
@@ -97,7 +95,7 @@ def infer_depth(prompt,
97
  image = None,
98
  ipa_img = None,
99
  negative_prompt = "nsfw,脸部阴影,低分辨率,糟糕的解剖结构、糟糕的手,缺失手指、质量最差、低质量、jpeg伪影、模糊、糟糕,黑脸,霓虹灯",
100
- seed = 397886929,
101
  randomize_seed = False,
102
  guidance_scale = 5.0,
103
  num_inference_steps = 50,
@@ -110,7 +108,7 @@ def infer_depth(prompt,
110
  seed = random.randint(0, MAX_SEED)
111
  generator = torch.Generator().manual_seed(seed)
112
  init_image = resize_image(image, MAX_IMAGE_SIZE)
113
- pipe = load_ipa(pipe_depth).to("cuda")
114
  pipe.set_ip_adapter_scale([ip_scale])
115
  condi_img = process_depth_condition_midas( np.array(init_image), MAX_IMAGE_SIZE)
116
  image = pipe(
@@ -134,7 +132,7 @@ def infer_canny(prompt,
134
  image = None,
135
  ipa_img = None,
136
  negative_prompt = "nsfw,脸部阴影,低分辨率,糟糕的解剖结构、糟糕的手,缺失手指、质量最差、低质量、jpeg伪影、模糊、糟糕,黑脸,霓虹灯",
137
- seed = 397886929,
138
  randomize_seed = False,
139
  guidance_scale = 5.0,
140
  num_inference_steps = 50,
@@ -147,7 +145,7 @@ def infer_canny(prompt,
147
  seed = random.randint(0, MAX_SEED)
148
  generator = torch.Generator().manual_seed(seed)
149
  init_image = resize_image(image, MAX_IMAGE_SIZE)
150
- pipe = load_ipa(pipe_canny).to("cuda")
151
  pipe.set_ip_adapter_scale([ip_scale])
152
  condi_img = process_canny_condition(np.array(init_image))
153
  image = pipe(
 
62
  force_zeros_for_empty_prompt=False
63
  )
64
 
65
+ for pipe in [pipe_depth, pipe_canny]:
 
66
  if hasattr(pipe.unet, 'encoder_hid_proj'):
67
  pipe.unet.text_encoder_hid_proj = pipe.unet.encoder_hid_proj
68
 
69
  pipe.load_ip_adapter(f'{ckpt_dir_ipa}' , subfolder="", weight_name=["ip_adapter_plus_general.bin"])
 
70
 
71
  @spaces.GPU
72
  def process_canny_condition(image, canny_threods=[100,200]):
 
95
  image = None,
96
  ipa_img = None,
97
  negative_prompt = "nsfw,脸部阴影,低分辨率,糟糕的解剖结构、糟糕的手,缺失手指、质量最差、低质量、jpeg伪影、模糊、糟糕,黑脸,霓虹灯",
98
+ seed = 66,
99
  randomize_seed = False,
100
  guidance_scale = 5.0,
101
  num_inference_steps = 50,
 
108
  seed = random.randint(0, MAX_SEED)
109
  generator = torch.Generator().manual_seed(seed)
110
  init_image = resize_image(image, MAX_IMAGE_SIZE)
111
+ pipe = pipe_depth.to("cuda")
112
  pipe.set_ip_adapter_scale([ip_scale])
113
  condi_img = process_depth_condition_midas( np.array(init_image), MAX_IMAGE_SIZE)
114
  image = pipe(
 
132
  image = None,
133
  ipa_img = None,
134
  negative_prompt = "nsfw,脸部阴影,低分辨率,糟糕的解剖结构、糟糕的手,缺失手指、质量最差、低质量、jpeg伪影、模糊、糟糕,黑脸,霓虹灯",
135
+ seed = 66,
136
  randomize_seed = False,
137
  guidance_scale = 5.0,
138
  num_inference_steps = 50,
 
145
  seed = random.randint(0, MAX_SEED)
146
  generator = torch.Generator().manual_seed(seed)
147
  init_image = resize_image(image, MAX_IMAGE_SIZE)
148
+ pipe = pipe_canny.to("cuda")
149
  pipe.set_ip_adapter_scale([ip_scale])
150
  condi_img = process_canny_condition(np.array(init_image))
151
  image = pipe(