JoPmt commited on
Commit
5cfe917
1 Parent(s): d49a0b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -26,7 +26,8 @@ from models.eva_clip.utils_qformer import resize_numpy_image_long
26
  os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
27
  os.environ["ZERO_GPU_PATCH_TORCH_DEVICE"] = "True"
28
  device = "cuda" if torch.cuda.is_available() else "cpu"
29
-
 
30
  hf_hub_download(repo_id="ai-forever/Real-ESRGAN", filename="RealESRGAN_x4.pth", local_dir="model_real_esran")
31
  snapshot_download(repo_id="AlexWortega/RIFE", local_dir="model_rife")
32
  snapshot_download(repo_id="BestWishYsh/ConsisID-preview", local_dir="BestWishYsh/ConsisID-preview")
@@ -87,7 +88,7 @@ face_helper.face_det.to(device)
87
  face_helper.face_parse.to(device)
88
  transformer.to(device, dtype=dtype)
89
 
90
- pipe = ConsisIDPipeline.from_pretrained(model_path, transformer=transformer, scheduler=scheduler, torch_dtype=dtype)
91
  # If you're using with lora, add this code
92
  if lora_path:
93
  pipe.load_lora_weights(lora_path, weight_name="pytorch_lora_weights.safetensors", adapter_name="test_1")
 
26
  os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True"
27
  os.environ["ZERO_GPU_PATCH_TORCH_DEVICE"] = "True"
28
  device = "cuda" if torch.cuda.is_available() else "cpu"
29
+ from accelerate import Accelerator
30
+ accelerator=Accelerator()
31
  hf_hub_download(repo_id="ai-forever/Real-ESRGAN", filename="RealESRGAN_x4.pth", local_dir="model_real_esran")
32
  snapshot_download(repo_id="AlexWortega/RIFE", local_dir="model_rife")
33
  snapshot_download(repo_id="BestWishYsh/ConsisID-preview", local_dir="BestWishYsh/ConsisID-preview")
 
88
  face_helper.face_parse.to(device)
89
  transformer.to(device, dtype=dtype)
90
 
91
+ pipe = accelerator.prepare(ConsisIDPipeline.from_pretrained(model_path, transformer=transformer, scheduler=scheduler, torch_dtype=dtype))
92
  # If you're using with lora, add this code
93
  if lora_path:
94
  pipe.load_lora_weights(lora_path, weight_name="pytorch_lora_weights.safetensors", adapter_name="test_1")