Lifeinhockey commited on
Commit
854eb45
·
verified ·
1 Parent(s): 8478c87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -6
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,6 +98,12 @@ 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
  # Преобразуем изображения
102
  source_image = preprocess_image(source_image, width, height)
103
  control_image = preprocess_image(control_image, width, height)
@@ -176,10 +182,11 @@ def infer(
176
 
177
  examples = [
178
  "A young man in anime style. The image is characterized by high definition and resolution. Handsome, thoughtful man, attentive eyes. The man is depicted in the foreground, close-up or in the middle. High-quality images of the face, eyes, nose, lips, hands and clothes. The background and background are blurred and indistinct. The play of light and shadow is visible on the face and clothes.",
 
179
  ]
180
 
181
  examples_negative = [
182
- "blurred details, low resolution, poor image of a man's face, poor quality, artifacts, black and white image",
183
  ]
184
 
185
  css = """
@@ -273,6 +280,7 @@ with gr.Blocks(css=css) as demo:
273
  value=512,
274
  )
275
 
 
276
  with gr.Blocks():
277
  with gr.Row():
278
  use_control_net = gr.Checkbox(
@@ -306,6 +314,7 @@ with gr.Blocks(css=css) as demo:
306
  inputs=use_control_net,
307
  outputs=control_net_options,
308
  )
 
309
 
310
  gr.Examples(examples=examples, inputs=[prompt])
311
  gr.Examples(examples=examples_negative, inputs=[negative_prompt])
 
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)
109
  control_image = preprocess_image(control_image, width, height)
 
182
 
183
  examples = [
184
  "A young man in anime style. The image is characterized by high definition and resolution. Handsome, thoughtful man, attentive eyes. The man is depicted in the foreground, close-up or in the middle. High-quality images of the face, eyes, nose, lips, hands and clothes. The background and background are blurred and indistinct. The play of light and shadow is visible on the face and clothes.",
185
+ "A man runs through the park against the background of trees. The man's entire figure, face, arms and legs are visible. Anime style. The best quality.",
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 = """
 
280
  value=512,
281
  )
282
 
283
+ # ControlNet ---------------------------------------------------------------------------------
284
  with gr.Blocks():
285
  with gr.Row():
286
  use_control_net = gr.Checkbox(
 
314
  inputs=use_control_net,
315
  outputs=control_net_options,
316
  )
317
+ # --------------------------------------------------------------------------------------
318
 
319
  gr.Examples(examples=examples, inputs=[prompt])
320
  gr.Examples(examples=examples_negative, inputs=[negative_prompt])