Lifeinhockey commited on
Commit
6b96774
·
verified ·
1 Parent(s): 854eb45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -11
app.py CHANGED
@@ -61,11 +61,11 @@ def align_embeddings(prompt_embeds, negative_prompt_embeds):
61
 
62
  pipe_default = get_lora_sd_pipeline(lora_dir='./lora_man_animestyle', base_model_name_or_path=model_default, dtype=torch_dtype).to(device)
63
  #pipe_controlnet = StableDiffusionControlNetPipeline.from_pretrained(
64
- # pipe_controlnet = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
65
- # model_default,
66
- # controlnet=controlnet,
67
- # torch_dtype=torch_dtype
68
- # ).to(device)
69
 
70
  def preprocess_image(image, target_width, target_height):
71
  """
@@ -98,11 +98,11 @@ def infer(
98
  generator = torch.Generator(device).manual_seed(seed)
99
 
100
  if use_control_net and control_image is not None and source_image is not None:
101
- pipe_controlnet = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
102
- model_default,
103
- controlnet=controlnet,
104
- torch_dtype=torch_dtype
105
- ).to(device)
106
 
107
  # Преобразуем изображения
108
  source_image = preprocess_image(source_image, width, height)
@@ -145,6 +145,7 @@ def infer(
145
  negative_prompt_embeds=negative_prompt_embeds,
146
  image=source_image,
147
  control_image=control_image,
 
148
  width=width,
149
  height=height,
150
  num_inference_steps=num_inference_steps,
@@ -186,7 +187,7 @@ examples = [
186
  ]
187
 
188
  examples_negative = [
189
- "Blurred details, low resolution, poor image of a man's face, poor quality, artifacts, black and white image",
190
  ]
191
 
192
  css = """
 
61
 
62
  pipe_default = get_lora_sd_pipeline(lora_dir='./lora_man_animestyle', base_model_name_or_path=model_default, dtype=torch_dtype).to(device)
63
  #pipe_controlnet = StableDiffusionControlNetPipeline.from_pretrained(
64
+ pipe_controlnet = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
65
+ model_default,
66
+ controlnet=controlnet,
67
+ torch_dtype=torch_dtype
68
+ ).to(device)
69
 
70
  def preprocess_image(image, target_width, target_height):
71
  """
 
98
  generator = torch.Generator(device).manual_seed(seed)
99
 
100
  if use_control_net and control_image is not None and source_image is not None:
101
+ # pipe_controlnet = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
102
+ # model_default,
103
+ # controlnet=controlnet,
104
+ # torch_dtype=torch_dtype
105
+ # ).to(device)
106
 
107
  # Преобразуем изображения
108
  source_image = preprocess_image(source_image, width, height)
 
145
  negative_prompt_embeds=negative_prompt_embeds,
146
  image=source_image,
147
  control_image=control_image,
148
+ strength=0.8, # Коэфф. зашумления, чем больше, тем больше меняется результирующее изображение относитенльно исходного
149
  width=width,
150
  height=height,
151
  num_inference_steps=num_inference_steps,
 
187
  ]
188
 
189
  examples_negative = [
190
+ "Blurred details, low resolution, no face visible, poor image of a man's face, poor quality, artifacts, black and white image.",
191
  ]
192
 
193
  css = """