nsfwalex commited on
Commit
d67a533
1 Parent(s): 4d12863

Update inference_manager.py

Browse files
Files changed (1) hide show
  1. inference_manager.py +6 -11
inference_manager.py CHANGED
@@ -304,14 +304,6 @@ class InferenceManager:
304
  if not sampler:
305
  sampler = self.cfg.get("sampler", "Euler a")
306
  # Define samplers
307
- samplers = {
308
- "Euler a": EulerAncestralDiscreteScheduler.from_config(temp_pipeline.scheduler.config),
309
- "DPM++ SDE Karras": DPMSolverSDEScheduler.from_config(temp_pipeline.scheduler.config, use_karras_sigmas=True),
310
- "DPM2 a": DPMSolverMultistepScheduler.from_config(temp_pipeline.scheduler.config),
311
- "DPM++ SDE": DPMSolverSDEScheduler.from_config(temp_pipeline.scheduler.config),
312
- "DPM++ 2M SDE": DPMSolverSDEScheduler.from_config(temp_pipeline.scheduler.config, use_2m=True),
313
- "DPM++ 2S a": DPMSolverMultistepScheduler.from_config(temp_pipeline.scheduler.config, use_2s=True)
314
- }
315
 
316
  # Set the scheduler based on the selected sampler
317
  temp_pipeline.scheduler = samplers[sampler]
@@ -380,8 +372,7 @@ class ModelManager:
380
  """
381
  print("downloading models")
382
  print("loading face analysis...")
383
- self.app = FaceAnalysis(name="buffalo_l", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
384
- self.app.prepare(ctx_id=0, det_size=(512, 512))
385
  #download_from_hf()
386
  self.ext_model_pathes = {
387
  "ip-adapter-faceid-sdxl": hf_hub_download(repo_id="h94/IP-Adapter-FaceID", filename="ip-adapter-faceid_sdxl.bin", repo_type="model")
@@ -509,10 +500,14 @@ class ModelManager:
509
  raise Exception(f"face images not provided")
510
  start = time.time()
511
  model.base_model_pipeline.to("cuda")
 
 
 
512
  print("extracting face...")
513
  faceid_all_embeds = []
514
  for image in images:
515
  face = image#cv2.imread(image)
 
516
  faces = self.app.get(face)
517
  faceid_embed = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
518
  faceid_all_embeds.append(faceid_embed)
@@ -539,7 +534,7 @@ class ModelManager:
539
  num_inference_steps=steps,
540
  generator=generator,
541
  num_images_per_prompt=1,
542
- output_type="pil",
543
  #callback_on_step_end=callback_dynamic_cfg,
544
  #callback_on_step_end_tensor_inputs=['prompt_embeds', 'add_text_embeds', 'add_time_ids'],
545
  ).images
 
304
  if not sampler:
305
  sampler = self.cfg.get("sampler", "Euler a")
306
  # Define samplers
 
 
 
 
 
 
 
 
307
 
308
  # Set the scheduler based on the selected sampler
309
  temp_pipeline.scheduler = samplers[sampler]
 
372
  """
373
  print("downloading models")
374
  print("loading face analysis...")
375
+ self.app = None
 
376
  #download_from_hf()
377
  self.ext_model_pathes = {
378
  "ip-adapter-faceid-sdxl": hf_hub_download(repo_id="h94/IP-Adapter-FaceID", filename="ip-adapter-faceid_sdxl.bin", repo_type="model")
 
500
  raise Exception(f"face images not provided")
501
  start = time.time()
502
  model.base_model_pipeline.to("cuda")
503
+ if not self.app:
504
+ self.app = FaceAnalysis(name="buffalo_l", providers=['CUDAExecutionProvider', 'CPUExecutionProvider'])
505
+ self.app.prepare(ctx_id=0, det_size=(512, 512))
506
  print("extracting face...")
507
  faceid_all_embeds = []
508
  for image in images:
509
  face = image#cv2.imread(image)
510
+ print(image)
511
  faces = self.app.get(face)
512
  faceid_embed = torch.from_numpy(faces[0].normed_embedding).unsqueeze(0)
513
  faceid_all_embeds.append(faceid_embed)
 
534
  num_inference_steps=steps,
535
  generator=generator,
536
  num_images_per_prompt=1,
537
+ #output_type="pil",
538
  #callback_on_step_end=callback_dynamic_cfg,
539
  #callback_on_step_end_tensor_inputs=['prompt_embeds', 'add_text_embeds', 'add_time_ids'],
540
  ).images